mardi 26 juillet 2016

Complex if statement returns everything true [duplicate]

This question already has an answer here:

Below is my code. I am trying to parse a DataFrame and store company matches. However, the if statement always returns true and everything is saved in the dataframe current_customers even though about 10 out of my 150 rows has a value > 97. Below my code is a sample of my data.

current_customers = pandas.DataFrame()
potential_customers = pandas.DataFrame()
for i in range(0, len(FDA_useful_companies_bing)):
    if combined_data['match token sort'].iloc[i] or combined_data['match ratio'].iloc[i] or combined_data['match partial ratio'].iloc[i] > 97:
        current_customers = current_customers.append(combined_data.ix[i,4::])
    else:
        potential_customers = potential_customers.append(combined_data.ix[i,4::])

Sample of my data

Company                             City            State       ZIP     FDA Company                 FDA City            FDA State   FDA ZIP Token sort ratio              match token sort  Ratio                           match ratio    Partial Ratio            match partial ratio
NOVARTIS                            Larchwood       IA          51241   HELGET GAS PRODUCTS INC     Kansas City         MO          64116   AIR PRODUCTS  CHEMICALS INC   73                OCEANIC MEDICAL PRODUCTS INC    59             LUCAS INC                78
BOEHRINGER INGELHEIM VETMEDICA INC  Sioux Center    IA          51250   SOUTHWEST TECHNOLOGIES INC  North Kansas City   MO          64116   SOUTHWEST TECHNOLOGIES        100               SOUTHWEST TECHNOLOGIES          92             SOUTHWEST TECHNOLOGIES   100

EDIT: Additionally, if there is a more efficient way to do this, I would love to hear.

Aucun commentaire:

Enregistrer un commentaire