I have the dataframe as below:
How do I match my previous value with my current value if the column val equals "yes"
I tried using the code below:
df['val'] = df['val'].replace('yes', np.nan).bfill().astype(str)
I am getting this output which is not what I wanted to.
can we use np.where along with the bfill?