I have daily time series data in a Pandas dataframe - I'd like to get monthly statistics, but preserve the daily timestep.
df = pd.Series(np.arange(365), index=pd.date_range("1900-01-01", periods=365)).to_frame('val')
df_mean = df.resample('M').std().add_suffix('_mth_mean')
In this instance, df_mean has a row for each month:
val_mth_mean
1900-01-31 15.0
1900-02-28 44.5
1900-03-31 74.0
I'd like those monthly values to be daily, ideally in the same dataframe:
val val_mth_mean
1900-01-01 0 15.0
1900-01-02 1 15.0
...
1900-01-31 31 15.0
1900-02-01 32 44.5
1900-02-02 33 44.5
Looking for a Pythonic/Pandonic solution without iteration.