Answers for "how to rename elements of a column in pandas"

0

dataframe rename column

df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})

# Option 1
df.rename({"A": "a", "B": "c"}, axis=1)

# Option 2
df.rename(columns={"A": "a", "B": "c"})

# Result
   a  c
0  1  4
1  2  5
2  3  6
Posted by: Guest on March-10-2021

Code answers related to "how to rename elements of a column in pandas"

Python Answers by Framework

Browse Popular Code Answers by Language