I have a dataframe that currently looks like this.
season date winner
59 2008 2008-04-18 KKR
60 2008 2008-04-19 CSK
61 2008 2008-04-19 DC
62 2008 2008-04-20 RCB
63 2008 2008-04-20 KKR
64 2008 2008-04-21 RR
There is a date column with the dates and a winner column with the name of the team that won on that date.
I am trying to make a bar chart race. For that, I need to to get the data for every single date separately, where each date has all the teams and the number of wins of those teams till that date.
I have arranged the date in a sorted manner and added a column where I have grouped the data by the "winner" column and used the cumcount function to get the cumulative count.
df["col"]=df.groupby(["winner"]).cumcount()+1
Now, it looks like this.
season date winner col
59 2008 2008-04-18 KKR 1
60 2008 2008-04-19 CSK 1
61 2008 2008-04-19 DC 1
62 2008 2008-04-20 RCB 1
63 2008 2008-04-20 KKR 2
64 2008 2008-04-21 RR 1
For any date, I have the data for the winner on that day, but I don't know how to get the data for the other teams on that date.
I have also looked at this answer but here the values not present in the name column on a particular day don't need to be used.
Basically, I need a function where I pass the date and I get the no of wins for each team till that date.
Any help would be greatly appreciated.