In Excel I have the count with relative (not absolute) reference Historical Wins
= COUNTIFS($D3:$D$13,$D2,$E3:$E$13,1)
How do I loop through all of the rows, and counting the historical occurrences of wins (ie Pos = 1) that a particular trainer has in Python (exclude the current result)? Is this possible?
You can get similar results as countifs
by doing this. Can you try
df[(df['columname']==D2) & (df['columname']==1)].shape[0]
Here D2
is whatever value you are trying to get the count of in the first column.
Edited based on the comment. This is for multiple values of D2
df.groupby(['D2_column_name']).count()
This will give you the count of all values of D2. You can do groupby
on multiple columns
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.