Description
Replicating example
In [1]: df = pd.DataFrame([[1,2],[3,4]],columns=pd.CategoricalIndex(list('AB')))
In [2]: df.describe()
AttributeError: 'DataFrame' object has no attribute 'value_counts'
The behaviour in this notebook seems like a bug to me. This is pandas 0.17.0.
In it, g
and gcat
are the results of two df.groupby(['medium', 'artist']).count().unstack()
operations. The only difference is that one of those operations is on df
where one of the columns that the groupby
operates over has been converted to Categorical.
g
and gcat
behave very differently. I've tried to pin this down to the exact operation in the split-apply-combine that causes the problem without much luck.
Slicing a column out of g
returns a Series as expected, while slicing a column out of gcat
returns a DataFrame (see cells 4 and 5).
g.describe()
works as expected, but gcat.describe()
raises the exception
AttributeError: 'DataFrame' object has no attribute 'value_counts'
and g['painting'] + g['sculpture']
works as expected but g['painting'] + g['sculpture']
raises
Exception: Data must be 1-dimensional