I am converting 1 minute candle to 5 minute candle as below:
df = df.resample("5min").agg({
'stock_name': 'first',
'tr_open': 'first',
'tr_high': 'max',
'tr_low': 'min',
'tr_close': 'last'
})
For some reason, I need the time when OHLC values were taken for this aggregation.
Meaning, tr_time_high should contain the time when the tr_high was HIGH in this 5min candle etc.
How can I achieve this in Pandas?
Thanks in advance.