Renaming Column Name Dataframe 1

Renaming Column Name Dataframe

df = df.rename(columns={'oldName1': 'newName1', 'oldName2': 'newName2'})

Here is what the above code is Doing:
1. We create a dictionary with the old column names as keys and the new column names as values.
2. We pass the dictionary to the rename() function.
3. The rename() function renames the columns in the DataFrame.

Similar Posts