Skip to content

Commit 6ea277f

Browse files
author
Bijay Regmi
authored
improved dataframe example to avoid confusion (#41182)
* improved dataframe example to avoid confusion * simplified explaination of nunique
1 parent ebf3b98 commit 6ea277f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pandas/core/frame.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9814,9 +9814,9 @@ def _get_data() -> DataFrame:
98149814

98159815
def nunique(self, axis: Axis = 0, dropna: bool = True) -> Series:
98169816
"""
9817-
Count distinct observations over requested axis.
9817+
Count number of distinct elements in specified axis.
98189818
9819-
Return Series with number of distinct observations. Can ignore NaN
9819+
Return Series with number of distinct elements. Can ignore NaN
98209820
values.
98219821
98229822
Parameters
@@ -9838,10 +9838,10 @@ def nunique(self, axis: Axis = 0, dropna: bool = True) -> Series:
98389838
98399839
Examples
98409840
--------
9841-
>>> df = pd.DataFrame({'A': [1, 2, 3], 'B': [1, 1, 1]})
9841+
>>> df = pd.DataFrame({'A': [4, 5, 6], 'B': [4, 1, 1]})
98429842
>>> df.nunique()
98439843
A 3
9844-
B 1
9844+
B 2
98459845
dtype: int64
98469846
98479847
>>> df.nunique(axis=1)

0 commit comments

Comments
 (0)