df.rename(columns={'old_name': 'new_name'}, inplace=True)
#suppy as dict the column name to replace
df1 = df.rename(columns={'Name': 'EmpName'})
print(df1)
data.rename(columns={'oldName':'newName'}, inplace=True)
df1 = df.rename(columns={'Name': 'EmpName'})
print(df1)
import pandas as pd
d1 = {'Name': ['Pankaj', 'Lisa', 'David'], 'ID': [1, 2, 3], 'Role': ['CEO', 'Editor', 'Author']}
df = pd.DataFrame(d1)
print('Source DataFrame:
', df)
df.rename(index={0: '#0', 1: '#1', 2: '#2'}, columns={'Name': 'EmpName', 'ID': 'EmpID', 'Role': 'EmpRole'}, inplace=True)
print('Source DataFrame:
', df)