I am trying to create a column where if the previous value in the same column meets a condition then that value must become the previous value. For example...
PREVIOUS col | CORRECT col
HW HW
HW HW
RF RF
FW FW
FW FW
FWRF FW
FW FW
As you can see 'FWRF' has changed to 'FW' if the PREVIOUS col value is == 'FW'. I am trying to get the [CORRECT col] to work but I have run into issues.
Heres what I have tried so far to no avail...
df['CORRECT col'] = df.loc[df['PREVIOUS col'].shift(-1) == 'FWRF', 'PREVIOUS col']
I have also tried to create 'if' statements for this to work and that was even worse... but I am still learning how to use pandas effectively as I can. Your help will be greatly appreciated.