Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

rename one dataframe column python

#suppy as dict the column name to replace
df1 = df.rename(columns={'Name': 'EmpName'})
print(df1)
Comment

pandas rename single column

data.rename(columns={'oldName':'newName'}, inplace=True)
Comment

pd dataframe single column rename


df1 = df.rename(columns={'Name': 'EmpName'})
print(df1)
Comment

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:
', df)

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

print('Source DataFrame:
', df)
Comment

PREVIOUS NEXT
Code Example
Python :: python pip Failed to build cryptography 
Python :: ffill dataframe python 
Python :: entropy formula pyhon 
Python :: python autocorrelation plot 
Python :: python how to see what pip packages are installed 
Python :: selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: 
Python :: how to raise the exception in __exit__ python 
Python :: __delattr__ python 
Python :: how to make chrome extension in python 
Python :: gogle query python simple 
Python :: ffmpeg python video from images 
Python :: get dict values in list python 
Python :: screen.onkey python 
Python :: merge all mp4 video files into one file python 
Python :: pandas change period to daily frequency 
Python :: python join dict 
Python :: extract text from pdf python 
Python :: python int16 
Python :: depth first search python recursive 
Python :: python-telegram-bot send file 
Python :: how to open a dataset in netcdf4 
Python :: python makedir 
Python :: integral python 
Python :: ascending, descending dict 
Python :: mypy clear cache 
Python :: logging 
Python :: python disable logging on unittest 
Python :: mulitplication symbo for unpacking in python 
Python :: django example 
Python :: download pytz python 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =