In my code, I use the following calculation for a column in the dataframe:
np.where(df_score['number'] ! = 0, 100 - ((100 * df_score[rank_column] -50)/df_score['number']), None)
,I have used df_score['number']! = 0
, but the code is still wrong, ZeroDivisionError: float division by zero
, even if I put df_score['number']! = 0
changed to df_score['number'] > 0
, why?
pandas version:1.1.5
numpy version:1.24.4
Here are my numbers:
12.00000
12.00000
12.00000
12.00000
12.00000
0.00000
0.00000
0.00000
0.00000
0.00000
12.00000
12.00000
12.00000
I want to know why it went wrong and what should be done to fix it?
Thank you for your help