values_counts()
时间: 2024-05-08 13:15:22 浏览: 23
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.
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)