I have a data set containing rain data. I'm wanting to set up a running rain accumulator using Pandas.
This is what I have:
def determinePrev(df):
#NEED TO CHANGE VALUE TO RUNNING VVVVVV#
df.loc[df['Rain'] > 0, 'Running']=df['Rain'].shift(1)+df['Rain']
return df
Running it like that works, but it's only appropriate if there are only two days of rain in a row. When replacing one of the latter 'Rain's with 'Running', I get KeyError: 'Running'.
I've been trying to find a solution but it feels like I'm not getting anywhere. I'm relatively new to Python so if you do have a solution, can you please give as much detail as possible?
Thanks!
EDIT: I should add I'm not wanting to count consecutive days, rather measure the amount of rain that has fallen over the consecutive rainy days.
EDIT #2: