Невозможно переиндексировать фрейм данных в Pandas - PullRequest
0 голосов
/ 26 апреля 2020

переиндексировать порядок столбцов

columnsTitles = (['Fips','State', 'County', 'Precincts', 'Votes', 'White',
       'Black', 'Hispanic', 'Asian', 'Amerindian', 'Other','Total Population',
       'Less Than High School Diploma', 'At Least High School Diploma',
       '(At Least Bachelors's Degree)', 'Graduate Degree', 'School Enrollment',
       'Median Earnings 2010', 'Children Under 6 Living in Poverty',
       'Adults 65 and Older Living in Poverty',
       'Preschool.Enrollment.Ratio.enrolled.ages.3.and.4',
       'Poverty.Rate.below.federal.poverty.threshold', 'Gini.Coefficient',
       'Child.Poverty.living.in.families.below.the.poverty.line',
       'Management.professional.and.related.occupations',
       'Service.occupations', 'Sales.and.office.occupations',
       'Farming.fishing.and.forestry.occupations',
       'Construction.extraction.maintenance.and.repair.occupations',
       'Production.transportation.and.material.moving.occupations',
       'SIRE_homogeneity', 'median_age', 'Low.birthweight', 'Teen.births',
       'Children.in.single.parent.households', 'Adult.smoking',
       'Adult.obesity', 'Diabetes', 'Sexually.transmitted.infections',
       'HIV.prevalence.rate', 'Uninsured', 'Unemployment', 'Violent.crime',
       'Homicide.rate', 'Injury.deaths', 'Infant.mortality'])
df_data.reindex(columns=columnsTitles)

Файл "", строка 5 "(по крайней мере, степень бакалавра)", "Степень магистра", "Зачисление в школу", ^ SyntaxError: неверный синтаксис

Есть идеи, как решить эту проблему? Спасибо!

1 Ответ

0 голосов
/ 26 апреля 2020

edit: извините, я не уделил достаточно внимания: в вашем коде есть несколько кавычек, которые нужно отбросить, попробуйте поставить "\" перед одинарными кавычками в ваших строках.

    '(At Least Bachelors\'s Degree)'
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...