Skip to content

Add example section to groupby.rst and one example #6304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion doc/source/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -722,4 +722,14 @@ To see the order in which each row appears within its group, use the

df.groupby('A').cumcount()

df.groupby('A').cumcount(ascending=False) # kwarg only
df.groupby('A').cumcount(ascending=False) # kwarg only

Examples
~~~~~~~~

Regroup columns of a DataFrame according to their sum, and sum the aggregated ones.

.. ipython:: python

df = pd.DataFrame({'a':[1,0,0], 'b':[0,1,0], 'c':[1,0,0], 'd':[2,3,4]})
df.groupby(df.sum(), axis=1).sum()