英文:
Finding average by grouping row values pandas dataframe
问题
我在Python中编写了这行代码,但没有得到期望的输出。有人可以帮我吗?
我尝试了许多分组方法,但我从未得到期望的输出。
英文:
data=df.groupby('Term')['Subject'].apply(tuple)
I wrote this line in python but I didn't achieved desired output. Can anyone help me out.
I tried many grouping methods but I never came up with the output.
答案1
得分: 1
如果你正在查看按Term
分组的Subject
列的平均值,你实际上相当接近了:
df.groupby('Term')['Subject'].mean()
英文:
If you are looking at the average of the Subject
column grouped by Term
, you were actually quite close:
df.groupby('Term')['Subject'].mean()
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论