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
The crus is that mode is not a reducer (like sum, mean) and such, nor is it a straight filter, like nth, or tail. Its like .value_counts which we don't directly support either via groupby
you can do this:
In [6]: df = DataFrame({'A' : [1,2,1,2], 'B' : [1,1,1,1]})
In [7]: df
Out[7]:
A B
0 1 1
1 2 1
2 1 1
3 2 1
In [8]: df.groupby('A').B.value_counts()
Out[8]:
A B
1 1 2
2 1 2
Name: B, dtype: int64
In [9]: df.groupby('A').B.apply(lambda x: x.mode())
Out[9]:
A
1 0 1
2 0 1
Name: B, dtype: int64
There is
mean
,max
,median
,min
andmad
yet nomode
forgroupby
objects. Is there a good reason? What if I add and issue pull-request?The text was updated successfully, but these errors were encountered: