0

I want to calculate the mean of values rolling over Datetime index with a window of an P period of time centering on a Q period of time.

I have a dataset that have records in second:

Time                    Temperature     
2017-11-28 22:00:03     58.34
2017-11-28 22:00:05     57.54
2017-11-28 22:00:07     58.18
2017-11-28 22:00:09     58.18
2017-11-28 22:00:12     58.18

I would like to group meaning the values 2.5 minutes before and after 5 minutes frecuency and get something like this:

Time                    Temperature     
2017-11-28 22:05:00     mean(5 minutes before and after)
2017-11-28 22:10:00     mean(5 minutes before and after)
2017-11-28 22:15:00     mean(5 minutes before and after)
2017-11-28 22:20:00     mean(5 minutes before and after)
2017-11-28 22:25:00     mean(5 minutes before and after)

I'm trying with

hum_sta.set_index('Time').groupby(pd.Grouper(freq='5Min')).rolling("5min").mean()

But I'm not getting what I want, I just getting Multiindex Pandas Dataframe:

               Time  Time                Temperature    
2017-11-28 22:00:00  2017-11-28 22:00:03 NaN
                     2017-11-28 22:00:05 57.94
                     2017-11-28 22:00:07 57.86
                     2017-11-28 22:00:09 58.18
                     2017-11-28 22:00:12 58.18
cs95
  • 379,657
  • 97
  • 704
  • 746
ambigus9
  • 1,417
  • 3
  • 19
  • 37

0 Answers0