pandas.api.typing.DataFrameGroupBy.value_counts
pandas 3.1.1 · GroupBy · method
Count occurrences of each value or row combination. Set normalize for proportions and dropna=False to keep missing values.
Call syntax
pd.api.typing.DataFrameGroupBy.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 |
list-like 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 or DataFrame