Home > Enterprise >  Fail to rename columns because of character-encoding symbols
Fail to rename columns because of character-encoding symbols

Time:01-25

I have a dataframe encoded in latin-1 and i want to rename a series of columns:

df=df.rename(columns={"DATE (YYYY-MM-DD)": 'local time',"AIR TEMP - DRY BULB HOURLY (°C)": 'air temp mean'...})

All other columns except of "AIR TEMP - DRY BULB HOURLY (°C)" and other column who has the superscript two symbol got their names changed and I think these last ones failed because of their symbols.

How can I solve this problem ?

CodePudding user response:

Try it with °C and set the charset to utf-8.

Or look at this question, possible dublicate How to get ° character in a string in python?

  •  Tags:  
  • Related