values_counts()
时间: 2024-05-08 18:15:22 浏览: 111
values_counts() is not a valid method in Python. However, the correct method name is value_counts() which is used to count the number of occurrences of unique values in a pandas Series or DataFrame column. It returns a pandas Series object with the unique values as the index and the count of each value as the values.
Syntax:
```python
s.value_counts(normalize=False, sort=True, ascending=False, bins=None, dropna=True)
```
Here,
- normalize: If True, returns the relative frequency of each unique value. Default is False.
- sort: If True, sorts the result by count in descending order. Default is True.
- ascending: If True, sort in ascending order. Default is False.
- bins: Used only for numerical data. Cuts the data into bins to calculate the count. Default is None.
- dropna: If True, removes missing values (NaN) from the count. Default is True.
阅读全文