Horje
Pandas rename columns by position Code Example
Pandas rename columns by position
df.rename(columns={ df.columns[1]: "your value" }, inplace = True)
rename one dataframe column python in inplace

import pandas as pd

d1 = {'Name': ['Pankaj', 'Lisa', 'David'], 'ID': [1, 2, 3], 'Role': ['CEO', 'Editor', 'Author']}

df = pd.DataFrame(d1)

print('Source DataFrame:\n', df)

df.rename(index={0: '#0', 1: '#1', 2: '#2'}, columns={'Name': 'EmpName', 'ID': 'EmpID', 'Role': 'EmpRole'}, inplace=True)

print('Source DataFrame:\n', df)




Python

Related
print 2 decimal places python Code Example print 2 decimal places python Code Example
find the area of a circle in python Code Example find the area of a circle in python Code Example
SSL: CERTIFICATE_VERIFY_FAILED mongo atlas Code Example SSL: CERTIFICATE_VERIFY_FAILED mongo atlas Code Example
feature selection python Code Example feature selection python Code Example
pandas earliest date in column Code Example pandas earliest date in column Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7