python - How to conditionally update DataFrame column in Pandas -
with dataframe, how can conditionally set rating
0 when line_race
equal zero?
line_track line_race rating foreign 25 mth 10 84 false 26 mth 6 88 false 27 tam 5 87 false 28 gp 2 86 false 29 gp 7 59 false 30 lch 0 103 true 31 leo 0 125 true 32 yor 0 126 true 33 asc 0 124 true
in other words, proper way on dataframe if columna = x columnb = y else columnb = columnb
df.loc[df['line_race'] == 0, 'rating'] = 0
Comments
Post a Comment