This method mentioned by @DataFrames is the way. The test.c .== 5 specifies which rows to choose, and the :d specifies which column to change within that row.
By the way, the (x==5) ? 1 : 0 syntax you mention is called the “ternary operator”. ifelse is something different, that’s also present in Julia (?ifelse will describe the difference, though the ternary operator and normal if are much more common than ifelse).
I get it, DataFrame users look down at for loop, but come on do we never play with big data? I know DataFrames.jl is not good at for loop because we traded for loop speed with less latency by not recording column type, but you can use DataFramesMeta.jl
@jling - can you please show your proposal so that we can compare timing on the same data?
Let us just settle on the use case: we want to measure timing of creating new column :d, I mention this, because if we wanted to update :d in place it would be a bit different syntax and faster:
Oh I didn’t see it was a reply quoting your solution. Yes, your solution is the best of both worlds – doesn’t have mask array, also doesn’t loop over eachrow()
(To make comprehension/ looping over eachrow() as fast, we need DataFramesMeta I think?)