For each row in the dataframe below, want to populate minlow and lowdate. minlow should find the lowest ‘low’ column in the future and then set minlow and lowdate. I have plenty of code examples using .loc/.iloc but these are slow as the dataframe is over 4Million records. Trying to find the most performant method.
Expected output |
---|
Index 0 would be nothing as no future records are lower |
Index 1 would have minlow=277.97 and lowdate=2020-01-20 21:39:00 |
Index 2 would be nothing as it is already at the lowest |
Index 3 would be nothing as no future records are lower |
Index 4 would be nothing as it is the last record and no future records exist yet |
date low minlow lowdate
0 2020-01-20 21:37:00 277.97 None None
1 2020-01-20 21:38:00 277.98 None None
2 2020-01-20 21:39:00 277.97 None None
3 2020-01-20 21:40:00 277.98 None None
4 2020-01-20 21:41:00 277.99 None None