-1

我正在学习如何进行数据科学,并且正在关注泰坦尼克号的 kaggle 教程

然而,

women_only_stats = data[                          \ #Which element           
                     (data[0::,4] == "female")    \ #is a female
                   &(data[0::,2].astype(np.float) \ #and was ith class
                         == i+1) \                       
                   &(data[0:,9].astype(np.float)  \#was greater 
                        >= j*fare_bracket_size)   \#than this bin              
                   &(data[0:,9].astype(np.float)  \#and less than
                        < (j+1)*fare_bracket_size)\#the next bin    
                      , 1]                        #in the 2nd col                           

我在第一行得到了这个错误(data[0::,4] == "female")

错误:

SyntaxError:行继续字符后出现意外字符

4

1 回答 1

1

您的代码(以及您从中复制的网站上的代码)带有反斜杠,后跟注释。例如

\ #is a female

反斜杠是“行继续符”。该错误告诉您不应有一个续行字符后跟更多文本(在本例中为注释)。

去掉反斜杠。

于 2015-09-20T09:35:13.253 回答