how to replace all elements in a column pands

Solutions on MaxInterview for how to replace all elements in a column pands by the best coders in the world

showing results for - "how to replace all elements in a column pands"
Giorgio
11 Sep 2019
1df = pd.DataFrame({"column1": ["a", "b", "a"]})
2print(df)
3OUTPUT
4  column1
50       a
61       b
72       a
8
9df["column1"].replace({"a": "x", "b": "y"}, inplace=True)
10print(df)
11OUTPUT
12  column1
130       x
141       y
152       x
similar questions