vendredi 15 juillet 2016

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

I have a data set with 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 is an SFrame. I have attempted to write a function that uses an if/an statement to determine if the value for dog-dog is less that the values for dog-ct AND dog-auto AND dog-bird.

I've gone through this for the better part of 4 hours. Admittedly I'm a newby to python - I'm making a illy mistake and just 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 I call the function with:

dog_distances.apply(is_dog_correct)

If this was working correctly, I would see "0" in every row but the fifth record. What is wrong with my if statement?

Full disclosure - this is coursework, but after spending 4 hours on this, I'm reaching for help!

Aucun commentaire:

Enregistrer un commentaire