Within Pandas, I would like to resample my dataframe and take the mean within a 5 hour period and within index level. My dataframe looks like: df
timestamp width length
name
10 2019-08-01 00:00:00 10.1 86.1
10 2019-08-01 00:00:10 10.0 86.2
10 2019-08-01 00:05:40 10.1 86.3
10 2019-08-01 00:05:50 10.0 86.2
8 2019-08-01 00:05:54 12.0 110.0
I would like to keep my 'name' variable as index (preferably not setting timestamp as index), like:
timestamp width length
name
10 2019-08-01 00:00:05 10.05 86.15
10 2019-08-01 00:05:45 10.05 86.25
8 2019-08-01 00:05:54 12.0 110.0
I tried:
df_resample = df.resample('5H', on='timestamp').mean()
But this will not perform within index level. Also it sets the datetime on the index which I try to avoid.