Answers for "how to rename columns in panda"

65

rename columns 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
Posted by: Guest on March-13-2020
8

rename df column

import pandas as pd
data = pd.read_csv(file)
data.rename(columns={'original':'new_name'}, inplace=True)
Posted by: Guest on June-02-2020
1

rename column pandas

>>> df.rename(str.lower, axis='columns')
   a  b
0  1  4
1  2  5
2  3  6
Posted by: Guest on June-10-2020

Python Answers by Framework

Browse Popular Code Answers by Language