Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在excel中,我有相对(非绝对)参考历史胜利的计数
= COUNTIFS($D3:$D$13,$D2,$E3:$E$13,1)
所以本质上,我如何遍历所有行,并计算特定培训师在 Python 中获得的胜利(即 Pos = 1)的历史发生次数(不包括当前结果) Python 对我来说相对较新,但仍然略超出我的精神上的把握。 这可能吗? 谢谢你的帮助。
countifs通过这样做,您可以获得类似的结果。你能试一下吗
countifs
df[(df['columname']==D2) & (df['columname']==1)].shape[0]
这D2是您尝试在第一列中计算的任何值。
D2
根据评论编辑。这是针对多个值的D2 df.groupby(['D2_column_name']).count() 这将为您提供 D2 的所有值的计数。您可以groupby在多个列上执行
df.groupby(['D2_column_name']).count()
groupby