Examples
import numpy as np
import pandas as pd
index = pd.Index([2, 2, 5, 3, 4, np.nan])
index.value_counts()
With normalize set to True, returns the relative frequency by dividing all values by the sum of values.
s = pd.Series([2, 2, 5, 3, 4, np.nan])
s.value_counts(normalize=True)
bins
Bins can be useful for going from a continuous variable to a categorical variable; instead of counting
unique apparitions of values, divide the index in the specified number of half-open bins.
s.value_counts(bins=3)
dropna
With dropna set to False we can also see NaN index values.
s.value_counts(dropna=False)