pandas.DataFrame.value_counts
pandas 3.1.1 · DataFrame · method
Count occurrences of each value or row combination. Set normalize for proportions and dropna=False to keep missing values.
Call syntax
DataFrame.value_counts(subset=None, normalize=False, sort=True, ascending=False, dropna=True)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
subset |
Optional Positional or keyword Default None |
Hashable or a sequence of the previous Restrict the operation to these labels instead of considering the whole object. |
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. |
dropna |
Optional Positional or keyword Default True |
bool Choose whether to drop missing values or missing keys from consideration. |
Returns
Series