Skip to content

Commit

Permalink
DOC add cumcount example to groupby.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
hayd committed Nov 14, 2013
1 parent 83386d8 commit b564798
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions doc/source/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -705,3 +705,16 @@ can be used as group keys. If so, the order of the levels will be preserved:
factor = qcut(data, [0, .25, .5, .75, 1.])
data.groupby(factor).mean()
Enumerate group items
~~~~~~~~~~~~~~~~~~~~~

To see the order in which each row appears within its group, use the
``cumcount`` method:

.. ipython:: python
df = pd.DataFrame(list('aaabba'), columns=['A'])
df
df.groupby('A').cumcount()

0 comments on commit b564798

Please sign in to comment.