我可以对它们进行分组和分类
df_players.groupby(['vehicle']).agg({'frags':sum}).sort_values(['frags'],ascending=False)
我如何对vehicles
进行分组,并像这样获得他们的获胜率:
编辑:(数据)
[
{"player": "bob", "vehicle": "a", "hasWon": True, "frags": 5},
{"player": "foo", "vehicle": "b", "hasWon": False, "frags": 3},
{"player": "bar", "vehicle": "c", "hasWon": True, "frags": 2}
]
解决方案
虚拟数据
我认为您需要对
hasWon
列的mean
进行聚合,因为True
像1
一样进行处理,然后按100
进行倍数,四舍五入,最后转换为列:我将只分配一个新列,以便只使用
mean
:相关问题 更多 >
编程相关推荐