Multiple conditions on a dataframe

In my code, I want to get some entry from my dataframe and apply multiple conditions (here: country-year). My code is:

df[(df[:year] .== year) & (df[:country] .== country_name),:crisisJST][1,1]

So I specify a year and a country and want to get the value that I have in column crisisJST. This went through in 0.5.2 without problems, but it throws now an error:

MethodError: &(::DataArrays.DataArray{Bool,1}, ::DataArrays.DataArray{Bool,1}) is ambiguous. Candidates:
  &(a::DataArrays.DataArray{Bool,N} where N, b::Union{AbstractArray{Bool,N} where N, Bool}) in DataArrays at C:\Users\Ilja\.julia\v0.6\DataArrays\src\operators.jl:390
  &(b::Union{AbstractArray{Bool,N} where N, Bool}, a::DataArrays.DataArray{Bool,N} where N) in DataArrays at C:\Users\Ilja\.julia\v0.6\DataArrays\src\operators.jl:390
Possible fix, define
  &(::DataArrays.DataArray{Bool,N} where N, ::DataArrays.DataArray{Bool,N} where N)

I am a bit clueless however about the meaning of this. Can anybody help me with it?

1 Like

You should use .&.

2 Likes

Thank you! :slight_smile: