Skip to content

Commit b564798

Browse files
committed
DOC add cumcount example to groupby.rst
1 parent 83386d8 commit b564798

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

doc/source/groupby.rst

+13
Original file line numberDiff line numberDiff line change
@@ -705,3 +705,16 @@ can be used as group keys. If so, the order of the levels will be preserved:
705705
factor = qcut(data, [0, .25, .5, .75, 1.])
706706
707707
data.groupby(factor).mean()
708+
709+
Enumerate group items
710+
~~~~~~~~~~~~~~~~~~~~~
711+
712+
To see the order in which each row appears within its group, use the
713+
``cumcount`` method:
714+
715+
.. ipython:: python
716+
717+
df = pd.DataFrame(list('aaabba'), columns=['A'])
718+
df
719+
720+
df.groupby('A').cumcount()

0 commit comments

Comments
 (0)