Home >Backend Development >Python Tutorial >How to modify Dataframe column names in python
This article will introduce you to two methods of modifying Dataframe column names in python. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
First create a new Dataframe
import pandas as pd
df = pd.DataFrame({'a':[1,2,3],'b':[1,2,3]})
as follows:
a b
0 1 1
1 2 2
2 3 31 , modify column name a and b to be A and B.
df.columns = ['A','B']
2. Only modify column name a to A
df.rename(columns={'a':'A'})
Related free learning recommendations: python video tutorial!
The above is the detailed content of How to modify Dataframe column names in python. For more information, please follow other related articles on the PHP Chinese website!