I'm trying to encode groups of shapes from the UFO sighting dataset to try and increase model accuracy but I'm not sure how to use a list as the condition for each conversion. Below is the code.
def shape_group(val):
if val == ['changed' | 'changing'| 'unknown' |'unspecified' | 'other']: # Uncertain
return 1
else:
return 0
its a reduced version but the idea is there. I originally tried with:
if val == ['changed' , 'changing', 'unknown' ,'unspecified' , 'other']
and
no_nan_df['shape_group'] = no_nan_df['shape'].apply(shape_type)
returns no matches
Thanks!
Aucun commentaire:
Enregistrer un commentaire