I have a function
def age_func(row):
if row["temp_col"] == 0 and set_flag == 0:
set_flag = 1
elif if row["temp_col"] == 1 and set_flag == 0:
***code**
else:
****code here****
#loops row-wise in the dataframe
df['final_col'] = ts.apply (lambda row: age_func(row), axis=1)
But want to loop through last row to first row for this code to work. Can anyone suggest me Any alternative approach by using lambda so that I can loop in reverse order.