Ad

Fail To Rename Columns Because Of Character-encoding Symbols

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 ?

Ad

Answer

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?

Ad
source: stackoverflow.com
Ad