I would like to change the value (c,d) where there is a duplicate name (a) AND condition = 'Cancel' (b)
import pandas as pd
data1 = {'a' : ['Mary','Mary','John','Jenny','Jenny'],
'b' : ['Approve','Cancel','Approve','Approve','Cancel'],
'c' : [100,200,300,400,500],
'd' : [200,200,300,400,500]
}
df1= pd.DataFrame(data1)
df1
I can select the specific rows using df1[(df1.duplicated(['a'], keep=False) & (df1['b']=='Cancel'))] but struggle to find a way to change values....I am researching np.where and df.apply
Thanks in advance.
