mercredi 14 mars 2018

Conditional loop in python using pandas

The below code snippet containing conditional statements is not working as expected. It's returning all 0s for usage['knozo'] where it should contain 1s as well for some rows. Can someone figure out where am I going wrong in this loop/condition?

for i in range(0,len(usage)):
    for j in range(0,len(knozo)):
        if usage['key_usage'].iloc[i] == knozo['key_knozo'].iloc[j]:
            usage['knozo'] = 1
        else:
            usage['knozo'] = 0
            break

Aucun commentaire:

Enregistrer un commentaire