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  How to break outer loop in Java?

Leave a Reply

Your email address will not be published. Required fields are marked *

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