This question already has an answer here:
im trying to add if / else statement depending on the result of the previously added column, but I get the below error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
below is my code: (all data is numerical data)
Main_df.loc[:,'X']= ((Main_df['Y'] / Main_df['Z']) - 1 ) * 100
if Main_df['Y'] > Main_df['Z']:
Main_df['X']= abs(Main_df['X'])
else:
Main_df['X']= - abs(Main_df['X'])
Aucun commentaire:
Enregistrer un commentaire