mercredi 3 avril 2019

If statement to compare columns in dataframe to change directory accordingly python

context: I am trying to compare the values of multiple columns in order to change my working directory.

Issues with the following code:

if df.loc[(df.Integer_1 != df.Integer_2) & (df.Available != 'unavailable')]:
    os.chdir(os.getcwd() + "/test_1")
elif df.loc[(df.Integer_1 == df.Integer_2) & (df.Available != 'unavailable')]:
    os.chdir(os.getcwd() + "/test_2")
elif df.loc[df.Available == 'unavailable']:
    os.chdir(os.getcwd() + "/test_3")
else:
    print('Out of range')

I get the following error: Screenshot of Error. Documentation wasnt very helpful in the matter...

Any help would be greatly appreciated, still new to working with dataframe, a general point in the right direction would be helpful, I'm sure I can arrive at the solution in due time :)

Aucun commentaire:

Enregistrer un commentaire