Renaming column names in Pandas

0 votes

How can  I change the column labels of a pandas Data Frame from:

['$a', '$b', '$c', '$d', '$e']

I wish to change it to this:

['a', 'b', 'c', 'd', 'e'].

Can someone help me do this?

May 5, 2022 in Python by Kichu
• 19,040 points
612 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Just assign it to the .columns attribute:

>>> df = pd.DataFrame({'$a':[1,2], '$b': [10,20]})
>>> df
   $a  $b
0   1  10
1   2  20

>>> df.columns = ['a', 'b']
>>> df
   a   b
0  1  10
1  2  20

I hope this helps you.

answered May 6, 2022 by narikkadan
• 86,360 points

edited Mar 5

Related Questions In Python

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to print just one column in pandas?

You can use the header to print ...READ MORE

answered Apr 4, 2019 in Python by TIna
11,280 views
0 votes
1 answer

How to create empty pandas dataframe only with column names?

You can do it like this: df=pd.DataFrame(columns=["Name","Old","Ne ...READ MORE

answered Apr 6, 2019 in Python by Hari
11,553 views
0 votes