diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index 1aec8561807c9..c45256c482e8f 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -170,7 +170,7 @@ def factorize(values, sort=False, order=None, na_sentinel=-1): def value_counts(values, sort=True, ascending=False, normalize=False, bins=None, dropna=True): """ - Compute a histogram of the counts of non-null values + Compute a histogram of the counts of non-null values. Parameters ---------- @@ -184,7 +184,7 @@ def value_counts(values, sort=True, ascending=False, normalize=False, bins : integer, optional Rather than count values, group them into half-open bins, convenience for pd.cut, only works with numeric data - dropna : boolean, default False + dropna : boolean, default True Don't include counts of NaN Returns diff --git a/pandas/core/base.py b/pandas/core/base.py index b43883885e962..d430b709e403e 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -247,9 +247,11 @@ def min(self): def value_counts(self, normalize=False, sort=True, ascending=False, bins=None, dropna=True): """ - Returns object containing counts of unique values. The resulting object - will be in descending order so that the first element is the most - frequently-occurring element. Excludes NA values. + Returns object containing counts of unique values. + + The resulting object will be in descending order so that the + first element is the most frequently-occurring element. + Excludes NA values by default. Parameters ---------- @@ -263,8 +265,8 @@ def value_counts(self, normalize=False, sort=True, ascending=False, bins : integer, optional Rather than count values, group them into half-open bins, a convenience for pd.cut, only works with numeric data - dropna : boolean, default False - Don't include counts of NaN + dropna : boolean, default True + Don't include counts of NaN. Returns ------- @@ -288,7 +290,14 @@ def unique(self): def nunique(self, dropna=True): """ - Return count of unique elements in the object. Excludes NA values. + Return number of unique elements in the object. + + Excludes NA values by default. + + Parameters + ---------- + dropna : boolean, default True + Don't include NaN in the count. Returns -------