Skip to content

TypeScript code snippet – 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
See also  PHP code snippet - How to call js function from ?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.