0

I have a .csv in the OHLCV Format (Open, High, Low, Close, Volume) with 15min tick, how can I convert it in a OHLCV with 1h or plus tick? I've seen that Pandas can generate tick but I don't know how to use it for covert the tick. This is the shape of the dataset:

Time,Open,High,Low,Close,Volume
2010-01-01 00:00,1.43285,1.43303,1.43224,1.43275
2010-01-01 01:00,1.4329,1.43305,1.43206,1.43249
2010-01-01 02:00,1.43301,1.43305,1.43218,1.43271
2010-01-01 03:00,1.43285,1.43306,1.43181,1.43209
2010-01-01 04:00,1.43284,1.43302,1.43182,1.43223
2010-01-01 05:00,1.43275,1.43306,1.43199,1.43268
2010-01-01 06:00,1.43331,1.43335,1.43268,1.43286
Matteo_Sid
  • 252
  • 1
  • 2
  • 11

1 Answers1

2

Use resample and you can convert into any frequency:

df.resample('1H', on='Time').agg({
    'Open': 'first',
    'High': 'max',
    'Low': 'min',
    'Close': 'last',
    'Volume': 'sum'
})
Code Different
  • 90,614
  • 16
  • 144
  • 163