You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In [8]: importpandas.util.testingastmIn [9]: s=pd.Series(tm.makeCategoricalIndex(k=100))
In [10]: s.value_counts()
Out[10]:
vcKH40vXR931Zn8J29dtype: int64In [11]: s.value_counts().indexOut[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.
The text was updated successfully, but these errors were encountered:
I think that is the logical consequence of having a categorical type in series and having a CategorialIndex, so OK for me!
It is similar as how df.groupby('cat').count() now also preserves this categorical type. So in that regard, it would only be consistent that value_counts returns that as well.
There can of course be some incompatibilities, such as with plotting afterwards, but that is similar as eg the groupby case (we had some reports on that, eg #10140)
Thoughts on this?
Now that we have
CategoricalIndex
(thanks Jeff), should that type be preserved so thatOut[11]
is aCategoricalIndex
? My use-case (not shown in this example) is when the original categories are ordered, you get yourvalue_counts
and then want to sort the index.The text was updated successfully, but these errors were encountered: