本文是《数据蛙三个月强化课》的第一篇总结教程,如果想要了解数据蛙社群,可以阅读给DataFrog社群同学的学习建议。温馨提示:如果您已经熟悉pandas,大可不必再看这篇文章,或是之挑选部分文章
数据分析的过程分组统计是一个最常见的场景了,下面我们一起来看下啊。
一:创建数据集
index = pd.Index(data=["Tom", "Bob", "Mary", "James", "Andy", "Alice"], name="name")
data = {
"age": [18, 30, 35, 18, 22, 30],
"city": ["Bei Jing ", "Shang Hai ", "Guang Zhou", "Shen Zhen", "Zhe Jiang", "Su Zhou"],
"sex": ["male", "male", "female", "male", "male", "female"],
"income": [3000, 8000, 8000, 4000, 6000, 7000]
}
user_info = pd.DataFram