I have a dataframe like this:
| Scores | Correct | Incorrect |
|---|---|---|
| 3 | 3 | 0 |
| 0 | 0 | 0 |
I am trying to update and normalize the 'Scores" column in such a way that
df['Scores'] = df['Scores'] / (df['Correct']+df['Incorrect])
But there may be some columns that can cause ZeroDivisionError as you can see in the second row of the dataframe. So I used this code but it still throws ZeroDivisionError:
df['Scores'] = np.where(((df['Correct']+df['Incorrect])>0), df['Scores'] / (df['Correct']+df['Incorrect]), df['Scores'])
What can I do in this scenario?