You can rename columns in Pandas dataframe by changing the array containing the column names.

The syntax for renaming columns in Pandas:

dataframe.columns = [['new_name', 'new_name', 'new_name']]

The following syntax can be demonstrated using an example in Python:

import pandas as pd

df = pd.DataFrame({'Name': ['Steve Smith', 'John Von Neumann', 'Jack Black'], 'Age':[32, 34, 36]})

df.head()

Now, renaming the first column,

df.columns = [['Full Name', 'Age']]

df.head()

This is how you rename a column in Pandas.

In Conclusion

Do you have any problems renaming a column in Pandas? Let us know in the comment section below.

LEAVE A REPLY

Please enter your comment!
Please enter your name here