比如说有一个名为 df1 的dataframe
要统计某一列(比如说列名是city)中各个值出现的次数
#可以通过df.colname 来指定某个列,value_counts()在这里进行计数
df2 = df1.city.value_counts()
print(df2)
- 1
- 2
- 3
还有一个是统计出现的个数: df.nunique(),
df.nunique() a 4 b 5 c 1 dtype: int64
https://blog.csdn.net/weixin_42389265/article/details/107013720?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param