Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas rename specific column

df.rename(columns={'old_name': 'new_name'}, inplace=True)
Comment

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 :: add field placeholder layout crispy modelform 
Python :: python image black and white 
Python :: python read file in string list 
Python :: how to check for duplicates in a column in python 
Python :: sacar la posicion en una lista python 
Python :: for loop with float python 
Python :: number of total words in cell pandas 
Python :: change python 3.5 to 3.6 ubuntu 
Python :: read bytes from file python 
Python :: how to print not equal to in python 
Python :: exact distance 
Python :: how to send a message from google form to a python 
Python :: where to find python3 interpreter 
Python :: filter function using lambda in python 
Python :: datetime to int python 
Python :: how to graph with python 
Python :: how to map array of string to int in python 
Python :: pandas describe get mean min max 
Python :: python command not found 
Python :: python check if variables are the same 
Python :: python get all methods of object 
Python :: dict to array of string python 
Python :: convert number to binary python 
Python :: crop image python 
Python :: python make api request 
Python :: python string exclude non alphabetical characters 
Python :: python create random matrix 
Python :: python split list of tuples in two lists 
Python :: how to insert sound in python 
Python :: corona 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =