Hacker News new | ask | show | jobs
by porker 1260 days ago
> f.loc[f['a'] <= 3, "b"] = f['b']

Why isn't that saying to assign the value of column b to these locations? Reading the code (and not being a Pandas user) I expected it to be

f.loc[f['a'] <= 3, "b"] = f['a']

Also the "// 10" comment is most confusing as looking at the result it matches 10, 20 & 30 in column b and replaces them with the matching values from column a

1 comments

In python // is integer division, comments start with #.
Boy I feel stupid. Thanks for setting me straight.