pandas.Index.value_counts
pandas 3.1.1 · Index objects · method
Count occurrences of each value or row combination. Set normalize for proportions and dropna=False to keep missing values.
Call syntax
Index.value_counts(normalize=False, sort=True, ascending=False, bins=None, dropna=True)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
normalize |
Optional Positional or keyword Default False |
bool Request normalized output, such as proportions for counts or midnight for datetimes. |
sort |
Optional Positional or keyword Default True |
bool Choose whether the resulting labels or groups are sorted where supported. |
ascending |
Optional Positional or keyword Default False |
bool Choose ascending or descending order. Some sorting methods take one flag per sort key. |
bins |
Optional Positional or keyword Default None |
int Set a number of bins or provide bin boundaries. |
dropna |
Optional Positional or keyword Default True |
bool Choose whether to drop missing values or missing keys from consideration. |
Returns
Series