jeudi 2 avril 2020

For Loops and if statements in Pandas Dataframe

I am trying to get row values is certain conditions are met

here is the code

response=108
group="MAMA"
optout='False'

for row in merged_df:
        if row==response & row==group & row==optout:
            print(merged_df['phone'])

My dataframe looks like so enter image description here

This is the error I get

    read_masterFacility()
  File "readsheet.py", line 48, in read_masterFacility
    if row==response & row==group & row==optout:
TypeError: unsupported operand type(s) for &: 'int' and 'str'

How can I do this better??

Aucun commentaire:

Enregistrer un commentaire