Skip to content

Python code snippet – How to change column name in pandas?

df.rename(columns={'oldName1': 'newName1',
                   'oldName2': 'newName2'},
          inplace=True, errors='raise')
# Make sure you set inplace to True if you want the change
# to be applied to the dataframe
See also  Python code snippet - How to get RGB value from pixel in screen live ?

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.