I have a DatetimeIndex with the name idx:
DatetimeIndex(['2020-10-24 21:00:00+03:00', '2020-10-24 23:00:00+03:00',
'2020-10-25 08:00:00+03:00', '2020-10-26 08:00:00+03:00',
'2020-10-27 13:00:00+03:00', '2020-10-29 07:00:00+03:00',
'2020-10-29 22:00:00+03:00', '2020-10-31 01:00:00+03:00',
'2020-11-01 16:00:00+03:00', '2020-11-03 18:00:00+03:00',
'2020-11-04 20:00:00+03:00', '2020-11-05 17:00:00+03:00'],
dtype='datetime64[ns, Europe/Moscow]', freq=None)
I need to iterate through dataframe rows to calculate cumulative max of 'close' column from each idx element to the next, then from the following to the next, and so on. It works well by doing:
for i in np.arange(len(idx)):
signals.loc[idx[i]:, 'close_max'] = signals.loc[idx[i]:, 'close'].cummax(axis=0)
But iterating a dataframe is not a good thing. Could you help to make this without for loop?

.apply()? It applies the function inside the parenthesis in the whole column