How to conditionally update DataFrame column in Pandas
Use numpy.where to say if ColumnA = x then ColumnB = y else ColumnB = ColumnB:
df['rating'] = np.where(df['line_race']==0, 0, df['rating'])
df.loc[df['line_race'] == 0, 'rating'] = 0
Use numpy.where to say if ColumnA = x then ColumnB = y else ColumnB = ColumnB:
df['rating'] = np.where(df['line_race']==0, 0, df['rating'])
df.loc[df['line_race'] == 0, 'rating'] = 0