I have a big Data Frame with full datetime as index and 2 columns with temperature in every minute (I don't know how to write code with dataframe with time index, sorry):
df = pd.DataFrame(np.array([[210, 211], [212, 215], [212, 215], [214, 214]]),
columns=['t1', 't2'])
t1 t2
2015-01-01 00:00:00 210 211
2015-01-01 00:01:00 212 215
2015-01-01 00:02:00 212 215
...
2015-01-01 01:05:00 240 232
2015-01-01 01:06:00 206 209
I have to make two new columns t1_mean and t2_mean which contains
- t1_mean - mean from first 30 minutes from hour wit beginning from 6 minute (from 2015-01-01 00:06:00 to 2015-01-01 00:35:00, for example)
- t2_mean - mean from last 30 minutes from hour wit beginning from 6 minute (from 2015-01-01 00:36:00 to 2015-01-01 01:05:00, for example) and this values have to be in last row of an hour with beginning from 6 minute (2015-01-01 01:05:00, for example)
it should like look like this:
t1 t2 t1_mean t2_mean
2015-01-01 00:00:00 210 211 NaN NaN
2015-01-01 00:01:00 212 215 NaN NaN
2015-01-01 00:02:00 212 215 NaN NaN
...
2015-01-01 01:05:00 240 232 220 228
2015-01-01 01:06:00 206 209 Nan NaN
...
2015-01-01 02:05:00 245 234 221 235
...
How to solve this task?
Thanks in advance for replies