Question:
I have two dataframes representing two monthly datasets. I am trying to roll back the values indf1
(current month) with the values in df2
(previous month) if the value in fb
is Y
. The actual dataset is thousands of records long and there are 30 or so columns that need to be reset/rolled back. The double for loops in the code below return null values in df1
.df1
.My expected output for
df1
is:Answer:
If I understood you right:If you have better answer, please add a comment about this, thank you!