python - Dumb error in my if/and statement - not seeing it -


i have data set float values:

dog-auto        dog-bird        dog-cat         dog-dog         result 41.9579761457   41.7538647304   36.4196077068   33.4773590373   0 46.0021331807   41.33958925     38.8353268874   32.8458495684   0 42.9462290692   38.6157590853   36.9763410854   35.0397073189   0 41.6866060048   37.0892269954   34.575072914    33.9010327697   0 39.2269664935   38.272288694    34.778824791    37.4849250909   0 40.5845117698   39.1462089236   35.1171578292   34.945165344    0 45.1067352961   40.523040106    40.6095830913   39.0957278345   0 41.3221140974   38.1947918393   39.9036867306   37.7696131032   0 41.8244654995   40.1567131661   38.0674700168   35.1089144603   0 45.4976929401   45.5597962603   42.7258732951   43.2422832585   0 

this sframe. have attempted write function uses if/an statement determine if value dog-dog less values dog-ct , dog-auto , dog-bird.

i've gone through better part of 4 hours. admittedly i'm newby python - i'm making illy mistake , not seeing it.

if statement:

def is_dog_correct(row):     if (dog_distances[dog_distances['dog-dog']] < dog_distances[dog_distances['dog-cat']]) & (dog_distances[dog_distances['dog-dog']] < dog_distances[dog_distances['dog-bird']]) & (dog_distances[dog_distances['dog-dog']] < dog_distances[dog_distances['dog-auto']]):         dog_distances['result'] = 1     else:         dog_distances['result'] = 0 

then call function with:

dog_distances.apply(is_dog_correct) 

if working correctly, see "0" in every row fifth record. wrong if statement?

full disclosure - coursework, after spending 4 hours on this, i'm reaching help!

change & , indicated previous comments. also, recommend break such long if statements multiple lines it's clearer , easier read.

def is_dog_correct(row):     if (dog_distances[dog_distances['dog-dog']] < dog_distances[dog_distances['dog-cat']]) ,         (dog_distances[dog_distances['dog-dog']] < dog_distances[dog_distances['dog-bird']]) ,        (dog_distances[dog_distances['dog-dog']] < dog_distances[dog_distances['dog-auto']]):         dog_distances['result'] = 1     else:         dog_distances['result'] = 0 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -