0

I'm trying to resample the data, however, it does not seem to be working properly. I want to have start-of-month data to start-of-month.

The code is the following

df = pd.read_csv('OSEBX_daily.csv')
df = data[['time', 'OSEBX GR']]

df['time'] = pd.to_datetime(df['time']).dt.normalize()
df.set_index('time', inplace=True)
df.index = pd.to_datetime(df.index)
df.resample('1M').mean()
df['returns'] = df['OSEBX GR'].pct_change()
plt.plot(df['returns'])

1 Answers1

1

You forget assign back:

df = df.resample('1M').mean()
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252