Answers for "how to replace all elements in a column pands"

0

how to replace all elements in a column pands

df = pd.DataFrame({"column1": ["a", "b", "a"]})
print(df)
OUTPUT
  column1
0       a
1       b
2       a

df["column1"].replace({"a": "x", "b": "y"}, inplace=True)
print(df)
OUTPUT
  column1
0       x
1       y
2       x
Posted by: Guest on June-18-2021

Code answers related to "how to replace all elements in a column pands"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language