I have two dataframes:
df:
index some_variable identifier1 identifier2
1 x AB2 AB3
2 x BB2 BB3
3 x CB2 CB3
4 y DB2 DB3
5 y EB2 EB3
dfa:
index some_variable identifier1 identifier2 identifier3
1 x AB5 AB3 AB3
2 x BB5 BB2 AB2
3 x CB5 CB2 AB5
4 y DB5 DB3 AB3
5 y EB5 EB3 AB3
if an element of df['identifier1'] is in dfa['identifier2'] replace for that index df['identifier2'] by dfa['identifier3'], if some_variable is equal to 'x'. So the condition is:
[(df['identifier1'].isin(dfa['identifier2'])&(df[some_variable]=='x')]
and I want:
index some_variable identifier1 identifier2
1 x AB2 AB3
2 x BB2 AB2
3 x CB2 AB5
4 y DB2 DB3
5 y EB2 EB3
I can set up the condition, but can't figure out how to get the output.
dfwill have no changes, since none of the values indf['identifier1']are indfa.