Working with a time series dataframe of below format with the first column as index:
08/11/2021, 100
08/12/2021, null
08/13/2021, null
08/14/2021, 160
I want to perform an interpolation to return
08/11/2021, 100
08/12/2021, 120
08/13/2021, 140
08/14/2021, 160
What's an effective way to get the row indices nearest to the first and last null values in my df without pulling out the iterrows() sledgehammer? (Assume there can be multiple spans of nulls throughout the series and I will repeat this operation every time the function encounters a null)
No need to do anything manually, just use interpolate:
df.interpolate()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With