I have a dataframe containing 3 columns. I want to subtract the last entry of
col2 from second to last entry of
col2 and see if the subtraction of last from second to last entry is greater than 10 difference. If so, I would like to get the corresponding value for last and second to last in first column and replace the value of second to last in first column with 'NaN', and create another dataframe as output. Is there any way i can do it in pandas?
col1 col2 col3 a 21 1 b 20 1 c 9 1 d 20 1
col1 col3 [d, 'NaN'] 1
Thanks in advance.