diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 86e7003681e98..6c49455d5171d 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -148,7 +148,7 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then MSG='Doctests frame.py' ; echo $MSG pytest -q --doctest-modules pandas/core/frame.py \ - -k"-axes -combine -itertuples -join -nunique -pivot_table -quantile -query -reindex -reindex_axis -replace -round -set_index -stack" + -k"-axes -combine -itertuples -join -pivot_table -quantile -query -reindex -reindex_axis -replace -round -set_index -stack" RET=$(($RET + $?)) ; echo $MSG "DONE" MSG='Doctests series.py' ; echo $MSG diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 8d089ab3a1949..032d68e2d3e8c 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -7279,32 +7279,43 @@ def f(x): def nunique(self, axis=0, dropna=True): """ - Return Series with number of distinct observations over requested - axis. + Count distinct observations over requested axis. + + Return Series with number of distinct observations. Can ignore NaN + values. .. versionadded:: 0.20.0 Parameters ---------- axis : {0 or 'index', 1 or 'columns'}, default 0 - dropna : boolean, default True + The axis to use. 0 or 'index' for row-wise, 1 or 'columns' for + column-wise. + dropna : bool, default True Don't include NaN in the counts. Returns ------- nunique : Series + See Also + -------- + Series.nunique: Method nunique for Series. + DataFrame.count: Count non-NA cells for each column or row. + Examples -------- >>> df = pd.DataFrame({'A': [1, 2, 3], 'B': [1, 1, 1]}) >>> df.nunique() A 3 B 1 + dtype: int64 >>> df.nunique(axis=1) 0 1 1 2 2 2 + dtype: int64 """ return self.apply(Series.nunique, axis=axis, dropna=dropna)