Skip to content Skip to sidebar Skip to footer

Remove Special Characters From Column Headers

I have a dictionary (data_final) of dataframes (health, education, economy,...). The dataframes contain data from one xlsx file. In one of the dataframes (economy), the column name

Solution 1:

It looks as though your column names are being imported/created as tuples. What happens if you try and reference them removing the brackets, but leaving a comma on the end, like so

data_final['economy']['Construction',]

or even with the brackets

data_final['economy'][('Construction',)]

Solution 2:

The syntax error should be related to the line

('Population(In '00)',),

The string contains a single quotation mark, which would usually mark the end of the string. If you want to use one in a string, you have to surround it by " of escape it as \'. Rsulting in a line like:

('Population(In \'00)',),

The same problem applies to your actual call, you have to escape the quotation mark there as well.

Post a Comment for "Remove Special Characters From Column Headers"