I have a dataset that looks like the below-
Prec Tmax Tmin Tmean
Date
2010-01-01 0.585135 3.901162 -2.057929 0.921617
2010-01-02 0.100535 -3.498832 -8.125136 -5.811984
2010-01-03 0.123689 -3.635599 -11.228860 -7.432230
2010-01-04 0.616149 -2.582895 -10.813682 -6.698288
2010-01-05 0.371212 -2.538388 -9.403697 -5.971043
....
This dataframe has some rows missing and I would like to insert these rows with the values of their previous row. Below is the code I am trying to insert the values at 2012-12-31 that would be equal to the values of 2012-12-30.
climate_al_new.loc["2012-12-31"] = climate_al_new.loc["2012-12-30"]
But this does not add any row in the dataframe, this results in nan values-
climate_al_new.loc["2012-12-31"]
> Prec Tmax Tmin Tmean
Date
2012-12-31 NaN NaN NaN NaN
And when I do the same for the year 2016, it does not add anything-
Prec Tmax Tmin Tmean
Date_____________________________
How can I insert a row?