When converting a column to a type categorical, and setting the some aesthetics property (aes()) to use it, I'm getting the following error:
NotImplementedError: isna is not defined for MultiIndex
For example, here's a reproducible example:
randCat = np.random.randint(0,2,500)
randProj = np.random.rand(1,500)
df = pd.DataFrame({'proj': np.ravel(randProj),'cat': np.ravel(randCat)})
df['cat'] = df['cat'].map({0:'firstCat', 1:'secondCat'})
df['cat'] = df['cat'].astype('category')
g = ggplot(aes(x='proj', color='cat',fill='cat'), data=df) + geom_density(alpha=0.7)
print(g)
I'm using pandas version 0.22.0
.
And ggplot 0.11.5
Interestingly enough, the plot comes out fine when I'm not setting the "cond" column to be a "categorical" type (remains as string). However, for different purposes I need this column to categorical.
A more complete trace of the error:
54 # hack (for now) because MI registers as ndarray
55 elif isinstance(obj, ABCMultiIndex):
---> 56 raise NotImplementedError("isna is not defined for MultiIndex")
57 elif isinstance(obj, (ABCSeries, np.ndarray, ABCIndexClass)):
58 return _isna_ndarraylike(obj)
NotImplementedError: isna is not defined for MultiIndex
Thanks, Eyal.