Teams Points Fouls
TeamA 12 4
TeamA 14 6
TeamB 25 9
TeamB 27 11
TeamB 29 13
TeamA 16 15
TeamA 18 7
def pointsmedian(points):
df = pd.DataFrame(points)
median_points = df[(df['Teams'] == 'TeamA') & (df['Points'])].median()
return median_points
我希望只返回A队得分的中位数,但是,我的代码也返回犯规的中位数。有什么建议吗
我想你在找这个:
如果您想仅为teamA获取,可以在
groupby
上使用loc
:相关问题 更多 >
编程相关推荐