API: value_counts on a Categorical Series should have a CategoricalIndex · Issue #10704 · pandas-dev/pandas (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
Thoughts on this?
In [8]: import pandas.util.testing as tm
In [9]: s = pd.Series(tm.makeCategoricalIndex(k=100))
In [10]: s.value_counts() Out[10]: vcKH 40 vXR9 31 Zn8J 29 dtype: int64
In [11]: s.value_counts().index Out[11]: Index(['vcKH', 'vXR9', 'Zn8J'], dtype='object')
Now that we have CategoricalIndex
(thanks Jeff), should that type be preserved so that Out[11]
is a CategoricalIndex
? My use-case (not shown in this example) is when the original categories are ordered, you get your value_counts
and then want to sort the index.