open_time open high low close volume
0 2024-01-31 23:59:00 42565.8 42569.9 42552.7 42552.7 59.705
1 2024-01-31 23:58:00 42595.8 42595.8 42563.5 42565.8 75.882
2 2024-01-31 23:57:00 42599.3 42599.3 42595.8 42595.8 12.515
3 2024-01-31 23:56:00 42589.6 42599.3 42589.5 42599.3 25.815
4 2024-01-31 23:55:00 42590.4 42594.0 42587.3 42589.6 12.476
5 2024-01-31 23:54:00 42593.1 42593.2 42587.6 42590.4 21.097
6 2024-01-31 23:53:00 42600.0 42600.0 42578.3 42593.1 57.818
7 2024-01-31 23:52:00 42590.1 42600.0 42590.0 42600.0 20.513
8 2024-01-31 23:51:00 42601.8 42601.8 42590.0 42590.1 14.209
9 2024-01-31 23:50:00 42618.6 42618.6 42601.8 42601.8 7.078
10 2024-01-31 23:49:00 42602.9 42620.0 42602.9 42618.6 8.912
11 2024-01-31 23:48:00 42591.0 42603.0 42591.0 42602.9 23.900
12 2024-01-31 23:47:00 42600.2 42600.2 42591.0 42591.0 43.929
13 2024-01-31 23:46:00 42616.0 42616.2 42600.2 42600.2 8.483
14 2024-01-31 23:45:00 42600.8 42621.5 42600.7 42616.0 13.942
df1['open_time'] = df.iloc[-1]['open_time']
df1['open'] = df.iloc[-1]['open']
df1['high'] = df.iloc[0:5]['high'].max()
df1['low'] = df.iloc[0:5]['low'].min()
df1['close'] = df.iloc[0]['close']
df1['volume'] = df.iloc[0:5]['volume'].sum()
open_time open high low close volume
0 2024-01-31 23:55:00 42590.4 42599.3 42552.7 42552.7 186.39
1 2024-01-31 23:50:00 42618.6 42618.6 42578.3 42590.4 120.72
2 2024-01-31 23:45:00 42600.8 42621.5 42591.0 42618.6 99.17
index = pd.date_range('1/1/2000', periods=9, freq='min')
df= pd.DataFrame(data=np.random.randint(1,10,(9,2)), index=index, columns=['A','B'])
df.resample('3min').agg({'A':'sum','B':'mean'})
Я создал фрейм с индексом временная последовательность (1 мин). сгруппировал по 3минуты и применил к каждой из колонок разные аггрегирующие функции.