DataFramesMeta.jl icon indicating copy to clipboard operation
DataFramesMeta.jl copied to clipboard

Short-circuiting AND for @subset

Open kescobo opened this issue 2 years ago • 0 comments

Currently, each conditional seems to be evaluated for @subset, it would be nice (and possibly more efficient?) to use short-circuiting evaluation

julia> df = DataFrame(a = ["xy", "yz", missing, "za"], b=rand(4));

julia> @rsubset(df, !ismissing(:a), !startswith(:a, "x"))
ERROR: MethodError: no method matching startswith(::Missing, ::St
ring)

As @bkamins said on slack, one can currently get this behavior using && explicitly:

julia> @rsubset(df, !ismissing(:a) && !startswith(:a, "x"))
2×2 DataFrame
 Row │ a        b
     │ String?  Float64
─────┼───────────────────
   1 │ yz       0.701172
   2 │ za       0.757161

kescobo avatar Nov 19 '21 19:11 kescobo