df
mapping = {(1): 2, (3): 4}
f = lambda x: mapping.get(x, x)
df.loc[df['B'] == 2, 'A'] = df.loc[df['B'] == 2, 'A'].map(f)
df
Pandas warning when using map: A value is trying to be set on a copy of a slice from a DataFrame