I have a pandas DF that has two columns, Day, and Data, reading from a csv file.
After reading, I add 3 columns "Days with condition 0", 1, and 2. For example, for the columns 'Days with condition 2' I do this:
DF['Days with condition 2'] = ''
DF['Days with condition 2'][DF['Data']==2]=1
What I need to do and can't figure out is how to calculate 'Days since condition' 0,1,2. For example, the 'Days since condition 2' should display 11 in index 19, since that's the number of rows since the last condition was triggered (index 8). Is there any pandas function to do this?