I am using Python 3, it might be a source of the problems.
I have a dataframe with columns ['genotype_cont', 0, 2.5, 5]. Trying to call attribute boxplot
I am getting following problem:
Code position: index.py, line 1344:
Original line: theDiff = sorted(set(self) - set(other))
fix:
def keyfunction(x):
if isinstance(x, int):
v = '0%d' % x
else:
v = x[0]
return v
theDiff = sorted(set(self) - set(other), key=keyfunction)
Comment From: TomAugspurger
Can you post a copy-pasteable example along with your pandas version (pd.__version__
)?
Comment From: DSLituiev
version = '0.15.2' (installed recently with pip)
example
import pandas as pd
import numpy as np
from pandas import DataFrame
zero_time_point = 0
idx =['iadf', '124f', 'grgr', 'werw', '324f', 'trgr', 'bhrw']
df = DataFrame({
zero_time_point: [1,3,5,7,8,7,9],
2.5 : [11,33,55,77,55,77,99],
'by1': ["red", "blue", "red","red", "blue", "red", "blue"],
'by2': ["wet", "dry", 99, 95, "damp", 95,
np.nan]
}, index = idx )
g = df.groupby(['by1','by2'])
g.boxplot(by = 'by1')
Comment From: TomAugspurger
Thanks. That doesn't raise an error for me (py3, 0.15.2). Are you getting a TypeError?
Comment From: DSLituiev
Indeed, pardon. Now it does:
import pandas as pd
import numpy as np
from pandas import DataFrame
zero_time_point = 0
idx =['iadf', '124f', 'grgr', 'werw', '324f', 'trgr', 'bhrw']
df = DataFrame({
zero_time_point: [1,3,5,7,8,7,9],
2.5 : [11,33,55,77,55,77,99],
'g' : [1,3,5,7,5,7,9],
'by1': ["red", "blue", "red","red", "blue", "red", "blue"],
}, index = idx )
df.boxplot(by = 'by1')
The error:
File "/home/dima/data/repos/slfn5/test_pandas_int_col.py", line 25, in <module>
df.boxplot(by = 'by1')
File "/usr/local/lib/python3.4/dist-packages/pandas/core/frame.py", line 4975, in boxplot
**kwds)
File "/usr/local/lib/python3.4/dist-packages/pandas/tools/plotting.py", line 2613, in boxplot
return_type=return_type)
File "/usr/local/lib/python3.4/dist-packages/pandas/tools/plotting.py", line 2997, in _grouped_plot_by_column
columns = data._get_numeric_data().columns - by
File "/usr/local/lib/python3.4/dist-packages/pandas/core/index.py", line 1173, in __sub__
return self.difference(other)
File "/usr/local/lib/python3.4/dist-packages/pandas/core/index.py", line 1344, in difference
theDiff = sorted(set(self) - set(other))
Comment From: TomAugspurger
Can't reproduce this anymore. Perhaps try updating.