I have this df:
data = {'Name': ['T', 'J', 'K', 'J', 'M', 'A', 'J', 'K','L', 'o', 'j' ], 'Match': [0,1,2,0,1,0,1,2,3,0,1]}
Df = pd.DataFrame(data)
I want to apply column, which show season for each match. Season sholud be more then previous every time when match value is 0.
What is important, number of matches in every season is different.
Out sholud be:
What do you suggest?
>Solution :
df['Season'] = (df['Match']==0).cumsum()
Turn zeros to True (1) and the rest to False (0), and cumulatively sum them, it will increment only when seeing a True