Skip to content

improved dataframe example to avoid confusion #41182

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
May 7, 2021
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
8 changes: 4 additions & 4 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -9803,9 +9803,9 @@ def _get_data() -> DataFrame:

def nunique(self, axis: Axis = 0, dropna: bool = True) -> Series:
"""
Count distinct observations over requested axis.
Count number of distinct elements in specified axis.

Return Series with number of distinct observations. Can ignore NaN
Return Series with number of distinct elements. Can ignore NaN
values.

Parameters
Expand All @@ -9827,10 +9827,10 @@ def nunique(self, axis: Axis = 0, dropna: bool = True) -> Series:

Examples
--------
>>> df = pd.DataFrame({'A': [1, 2, 3], 'B': [1, 1, 1]})
>>> df = pd.DataFrame({'A': [4, 5, 6], 'B': [4, 1, 1]})
>>> df.nunique()
A 3
B 1
B 2
dtype: int64

>>> df.nunique(axis=1)
Expand Down