What is the fastest way to compute the number of occurrences of elements within a Pandas series?
My current fastest solution involves .groupby(columnname).size()
. Is there anything faster within Pandas? E.g. I want something like the following:
In [42]: df = DataFrame(['a', 'b', 'a'])
In [43]: df.groupby(0).size()
Out[43]:
0
a 2
b 1
dtype: int64