I want to filter values within a column and assign a value to the filtered results. However I get incorrect results, In this case, I want to assign a value of 1 to values between 20 and 30 and the rest 0. But I get 1 for all values. Any ideas why?
df = DataFrame(
Dict(
"time" => collect(1:10),
"cost" => [23,99,81,56,28,31,98,34,21,17]
)
)
df.cat = missing
df.cat = ifelse.(df.cost .> 20 .& df.cost .< 30, 1,0)
out:
