Skip to content

DOC: add unqiue value counts example to groupyby guide #37847

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 7 commits into from
Nov 25, 2020
Merged
Changes from 3 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
7 changes: 7 additions & 0 deletions doc/source/user_guide/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,13 @@ index are the group names and whose values are the sizes of each group.

grouped.describe()

Another aggregation example is to compute the number of unique values of a group. This is similar to the ``value_counts`` function, execpt that ``value_counts`` return the number of all values instead of the number of unique values.

.. ipython:: python

ll = [['foo', 1], ['foo', 2], ['foo', 2], ['bar', 1], ['bar', 1]]
pd.DataFrame(ll, columns=['A', 'B']).groupby('A').nunique()

.. note::

Aggregation functions **will not** return the groups that you are aggregating over
Expand Down