I need to know the amount of rainfall between two consecutive measurements of soil moisture (SM) and the difference in soil moisture (deltaSM).
df= pd.read_excel(‘Dataset.xlsx’)
df[‘Datetime’]=pd.to_datetime(df[‘Date’])
df=df.set_index(‘Datetime’)
My data look like this:
Date SM Rain
01/01/2016 0.23 0
02/01/2016 – 0
03/01/2016 – 10
04/01/2016 0.15 0
05/01/2016 0.30 0.1
06/01/2016 – 0
07/01/2016 – 5.2
08/01/2016 – 12.3
05/01/2016 0.40 0.5
06/01/2016 – 0
07/01/2016 0.25 0
08/01/2016 – 0
.
.
.
I would like to get:
Date SM Rain deltaSM Rsum
01/01/2016 0.23 0 – 0
02/01/2016 – 0 – –
03/01/2016 – 10 – –
04/01/2016 0.15 0 -0.08 10.0
05/01/2016 0.30 0.1 0.15 0.1
06/01/2016 – 0 – –
07/01/2016 – 5.2 – –
08/01/2016 – 12.3 – –
05/01/2016 0.40 0.5 0.10 18.0
06/01/2016 – 0 – –
07/01/2016 0.25 0 -0.15 0
08/01/2016 – 0 – –
I’m a beginner, I tried different approaches but failed to work. Thanks for any help you can give me!
Sofia Ortenzi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.