更改

跳转至: 导航搜索

使用Pandas统计元素出现次数

添加144字节, 2021年6月19日 (六) 16:53
无编辑摘要
import numpy as np
df = pd.DataFrame({'姓名':['张三','李四','王五','赵六','刘七'],'性别':['男','女','男','男','女'],'年龄':[25,17,30,20,17],'兴趣':['篮球','跑步','排球','游泳','足球']})
[[File:PythonPandas1.png]]
 
2.使用print(df['性别'].value_counts())即可打印出“性别”的统计次数。
[[File:PythonPandas2.png]]
1,138
个编辑

导航菜单