Skip to content

DOC: Added example of using OrderedDict for agg. #13938

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

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions doc/source/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
matplotlib.style.use('ggplot')
import matplotlib.pyplot as plt
plt.close('all')
from collections import OrderedDict

*****************************
Group By: split-apply-combine
Expand Down Expand Up @@ -487,6 +488,15 @@ must be either implemented on GroupBy or available via :ref:`dispatching

grouped.agg({'C' : 'sum', 'D' : 'std'})

Note that if you pass a dict to ``aggregate``, the ordering of the output colums is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put this in a .. note:: (you need to indent as well)

non-deterministic. If you want to be sure the output columns will be in a specific
order, you can use an ``OrderedDict``. Compare the output of the following two commands:

.. ipython:: python

grouped.agg({'D': 'std', 'C': 'mean'})
grouped.agg(OrderedDict([('D', 'std'), ('C', 'mean')]))

.. _groupby.aggregate.cython:

Cython-optimized aggregation functions
Expand Down