This is a result of the weird precedence of &. Try this:

(df[:A] .== 1) & (df[:B] .== 1)

 — John

On May 16, 2014, at 8:25 AM, Jason Solack <[email protected]> wrote:

> Hello all
> 
> I'm trying to index a dataframe in the folowing manner:
> 
> df = DataFrame(A = round(rand(1000) * 10), B = round(rand(1000) * 10))
> df[:C] = 0
> df[(df[:A] .== 1 & df[:B] .== 1),: C] = 1
> 
> 
> I get an error "ERROR: no method &(Int64, DataArray{Float64, 1})
> 
> if i index like this, it works but i won't be able to do "ors"
> 
> df[(df[:A] .== 1 .* df[:B] .== 1),: C] = 1
> 
> is there another way of going about this?
> 
> Thank you, 
> 
> Jason

Reply via email to