jeudi 18 mars 2021

'type' object is not subscriptable - IF LOOP ERROR

I have the following loop

LDFail = pd.DataFrame(data, columns=['ws_ms', 'large_door_failure', 'damage_state', '_project'])
Failure = LDFail['large_door_failure']
DamageState = []
for x in Failure:
    if (Failure == pd.Series['No','None', [0],'Unknown']).any():
        DamageState.append(0)
    else:
        DamageState.append(1)

When I try and determine if there is a large door failure (which can be any of the four values) I get the error:

   if (Failure == pd.Series['No','None', [0],'Unknown']).any():
TypeError: 'type' object is not subscriptable

Aucun commentaire:

Enregistrer un commentaire