【发布时间】:2021-08-27 08:48:28
【问题描述】:
我目前正在学习使用 python 3。
我正在按照提供的说明/演练进行一些练习。
我在尝试更改列名时开始收到以下错误:
File "<ipython-input-25-591a166ee92a>", line 5
'human development index (male)':"hdi_m"
^
SyntaxError: invalid syntax
这是我使用的代码:
gender_development.rename(columns={'gdi rank':"gdi_rank",
'gender development index (gdi)':"gdi"
'human development index (male)':"hdi_m"
'life expectancy at birth (female)':"life_expectancy_f"
'life expectancy at birth (male)':"life_expectancy_m"
'expected years of educaton (female)':"expected_education_years_f"
'expected years of education (male)':"expected_education_years_m"
'mean years of education (female)':"mean_education_years_f"
'mean years of education (male)':"mean_education_years_m"
'estimated gross national income per capita (female)':"gross_income_pc_f"
'estimated gross national income per capita (male)':"gross_income_pc_m"
'human development index (female)':"hdi_f"},
inplace=True)
有什么想法吗?
【问题讨论】:
-
字典中每一行的末尾都需要逗号。
标签: python python-3.x dictionary syntax-error