pandas DatetimeIndex .
rolling_mean, , .
import numpy as np
import pandas
df = pandas.DataFrame({'times': np.array(['1994-07-25 15:15:00.000',
'1994-07-25 16:00:00.000',
'1994-07-26 18:45:00.000',
'1994-07-27 15:15:00.000',
'1994-07-27 16:00:00.000',
'1994-07-28 18:45:00.000',
'1994-07-28 19:15:00.000',
'1994-07-28 20:35:00.000',
'1994-07-28 21:55:00.000',
'1994-07-29 14:15:00.000',
'1994-07-30 15:35:00.000',
'1994-07-30 16:55:00.000'], dtype='datetime64'),
'data': [165,165,165,165,165,165,63,64,64,62,62,61]})
df = df.set_index('times')
g = df.groupby(df.index.date)
days = 3
pandas.rolling_mean(g.sum(), days)
:
1994-07-25 NaN
1994-07-26 NaN
1994-07-27 275.000000
1994-07-28 283.666667
1994-07-29 249.333333
1994-07-30 180.333333
, center
min_periods
rolling_mean
, , .