-1

i am learning how to do data science and was following the kaggle tutorial for titanic.

However,

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                           

I got this error on the first line of (data[0::,4] == "female")

Error:

SyntaxError: unexpected character after line continuation character

cchamberlain
  • 17,444
  • 7
  • 59
  • 72
aceminer
  • 4,089
  • 9
  • 56
  • 104

1 Answers1

1

Your code (and the code on the website you copied from) has backslashes followed by comments. E.g.

\ #is a female

The backslash is the "line continuation character". The error is telling you you shouldn't have a line continuation character followed by more text (in this case a comment).

Take out the backslashes.

khelwood
  • 55,782
  • 14
  • 81
  • 108