find a value in dataframe and replace it with another value

In [1]:
import pandas as pd

In [2]:
df = pd.DataFrame([['One', 'Two'], ['Four', 'Abcd'], ['One', 'Bcd'], ['Five', 'Cd']], columns=['A', 'B'])

In [3]:
df


Out[3]:
A B
0 One Two
1 Four Abcd
2 One Bcd
3 Five Cd

In [4]:
df.loc[df['A'] == 'One', 'A'] = 0

In [5]:
df


Out[5]:
A B
0 0 Two
1 Four Abcd
2 0 Bcd
3 Five Cd

In [ ]: