How to handle a DataFrame deprecation of `&` in v0.6


#1

In v0.5 I did this:

using DataFrames
df = DataFrame(A = rand(5), 
        B = rand(1:10, 5), 
        C = ["a", "e", "i", "o", "u"])
df[(df[:A] .> 0.2) & (df[:B] .< 3), :] 

1×3 DataFrames.DataFrame
│ Row │ A        │ B │ C   │
├─────┼──────────┼───┼─────┤
│ 1   │ 0.386271 │ 1 │ "e" │

(Seems to work...)

In v0.6 I now get a deprecation warning:

WARNING: a::DataArray{$(Expr(:<:, :Integer))} & b::DataArray{$(Expr(:<:, :Integer))} 
is deprecated, use &.(a, b) instead.

But I can’t work out how to rephrase the expression to make it work…


#2

Just put a dot . in front of the & to broadcast it over all the elements:

df[(df[:A] .> 0.2) .& (df[:B] .< 3), :] 

works on my system on julia 0.6.


#3

Thanks! I didn’t try that one… :slight_smile: