pythonsyntax-errordata-dictionaryinvalid-characters

Invalid character identifier error within a data dictionary


I am trying to make dataframe for a final project at school. I have already calculated the numbers for everything, however, Python is not happy with the data dictionary that I am making. I have tried making the numbers into strings but the same syntax error kept popping up and I'm not sure on what to do about it.

# The 10 min average PM 2.5 time in the interval of the traffic signal 

 avg_pm10_traffic_joint= {'Average Cycle Length (Min)': [2.944444, 2.888889, 2.277778, 2.166667, 2.055556],
                          'PM 2.5 (10 Min Avg)':[45.13, 42.05, 40.75, 40.14, 39.31],
                          'Average PM 2.5 per Traffic Signal Cycle Rate (Rate = 2.944 (Min))': [13.286, 12.379, 11.996, 11.817, 11.572‬],
                          'Average PM 2.5 per Traffic Signal Cycle Rate (Rate = 2.899 (Min))': [13.083‬, 12.190, 11.813, 11.636, 11.395‬],
                          'Average PM 2.5 per Traffic Signal Cycle Rate (Rate = 2.277 (Min))': [10.276, 9.574, 9.278‬, 9.139‬, 8.950‬],
                          'Average PM 2.5 per Traffic Signal Cycle Rate (Rate = 2.166 (Min))': [9.775‬, 9.108, 8.826‬, 8.694‬, 8.514‬ ],
                          'Average PM 2.5 per Traffic Signal Cycle Rate (Rate = 2.055 (Min))': [9.274‬, 8.641‬, 8.374‬, 8.248, 8.078‬] 
                     }

It gives:

Output: File "<ipython-input-8-a3a71d8fb5de>", line 6
'Average PM 2.5 per Traffic Signal Cycle Rate (Rate = 2.944 (Min))': [13.286‬, 12.379, 11.996, 11.817, 11.572‬],                                                                                                                                                             
SyntaxError: invalid character in identifier

The arrow pointing to the error is at the first comma after 13.286 (I just couldn't get the arrow lined in the body of this message).


Solution

  • When I look at this code in Vim, I see <202c> periodically throughout your lists. That is what is causing the problem. You may want to look at it with a different text editor in order to remove those factors.

    Try copying this :

    avg_pm10_traffic_joint= {'Average Cycle Length (Min)': [2.944444, 2.888889, 2.277778, 2.166667, 2.055556],
        'PM 2.5 (10 Min Avg)':[45.13, 42.05, 40.75, 40.14, 39.31],
        'Average PM 2.5 per Traffic Signal Cycle Rate (Rate = 2.944 (Min))': [13.286, 12.379, 11.996, 11.817, 11.572
        'Average PM 2.5 per Traffic Signal Cycle Rate (Rate = 2.899 (Min))': [13.083, 12.190, 11.813, 11.636, 11.395
        'Average PM 2.5 per Traffic Signal Cycle Rate (Rate = 2.277 (Min))': [10.276, 9.574, 9.278, 9.139, 8.950
        'Average PM 2.5 per Traffic Signal Cycle Rate (Rate = 2.166 (Min))': [9.775, 9.108, 8.826, 8.694, 8.514],
        'Average PM 2.5 per Traffic Signal Cycle Rate (Rate = 2.055 (Min))': [9.274, 8.641, 8.374, 8.248, 8.078] 
    }