简体   繁体   中英

SyntaxError: invalid syntax - python dictionary attribute

Good Morning I am new to Data Science, I am doing data exploration, I created a dictionary (tax), when I am going to assign the (tax) created in my DF, it gives a syntax error.

df['TAX_PRESENT'] = [tax[resp] for resp in df.TAX CLASS AT PRESENT]

  File "<ipython-input-283-f131f0d2d00f>", line 1
    df['TAX_PRESENT'] = [tax[resp] for resp in df.TAX CLASS AT PRESENT]
                                                      ^
SyntaxError: invalid syntax

您似乎忘记用下划线连接列的名称:

df['TAX_PRESENT'] = [tax[resp] for resp in df.TAX_CLASS_AT_PRESENT]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM