invalid syntax 就是语法错误
常见的场景:
1、在使用筛选时使用等号:例如data['car']==2
data[‘car’]==2写成data['car']=2
2、换行时没有使用换行符,直接回车换行
hangzhou =
zhewan_score_original[zhewan_score_original.城市 == '杭州市']
File "", line 1
hangzhou =
^
SyntaxError: invalid syntax
#正确
hangzhou = \
zhewan_score_original[zhewan_score_original.城市 == '杭州市']
3、
无脑错误,多了一个(
for i in female_start.index:
if (female_start.at[i,'安装时间'] is None:
female_start.at[i,'是否安装'] = '未安装'
else:
female_start.at[i,'是否安装'] = '安装'
#正确
for i in female_start.index:
if female_start.at[i,'安装时间'] is None:
female_start.at[i,'是否安装'] = '未安装'
else:
female_start.at[i,'是否安装'] = '安装'