Python 按列分组,熊猫
如何计算第二列的平均值和第一列的groupby对象Python 按列分组,熊猫,python,jupyter,Python,Jupyter,如何计算第二列的平均值和第一列的groupby对象 area sallary 1 life 3500 2 life 3800 3 science 5000 4 other 4000 5 science 3000 6 other 5000 mean_life = 3650 mean_science = 4000 mean_other = 4500 使用: 您可以使用以下代码: df.groupby(['area'
area sallary
1 life 3500
2 life 3800
3 science 5000
4 other 4000
5 science 3000
6 other 5000
mean_life = 3650
mean_science = 4000
mean_other = 4500
使用:
您可以使用以下代码:
df.groupby(['area']).mean()
谢谢您。为我感到羞耻,那很容易。我编程的第一步。谢谢。为我感到羞耻,那很容易。我在编程方面的第一步。如果你以前没有尝试过,那就不容易了:)祝你好运!
df.groupby(['area']).mean()