I am trying to rename specific columns in a pandas.DataFrame
so I can concat
it with a similar dataframe. The code I ran is compiling but it doesn't successfully rename the columns.
df4.rename(columns={"Level1":"PctLevel1","Level2":"PctLevel2","Level3":"PctLevel3","Level4":"PctLevel4"})
You just have to reassign the code to df4
.
df4 = df4.rename(columns={"Level1":"PctLevel1","Level2":"PctLevel2","Level3":"PctLevel3","Level4":"PctLevel4"})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.