'I just want a resampled dataframe

How do I get the exact values back from a dataframe, just sampled at monthly intervals? If I say this, df is no longer a dataframe?

df.set_index('Date', inplace=True)
df.index = pd.to_datetime(df.index)
df.resample('1M')

So if df is say OHLC on daily data, I want df to be OHLC on monthly data.

It seems like there used to be a how, but now I get an error:

df= df.resample('1M', how=ohlc_dict)

It's incredible, all the resample and groupby examples apply a function after resampling or grouping. Talk about side effects. I just want the same dataframe at a different sampling rate!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source