jkrumbiegel / DataFrameMacros.jl

Macros that simplify working with DataFrames.jl
MIT License
61 stars 4 forks source link

`@subset` should have implicit skipmissing = true, or provide an option to specify #7

Closed tobi-lipede-oodle closed 3 years ago

tobi-lipede-oodle commented 3 years ago

This is an awesome package :) - I really like the 'rowwise by default' operations.

Currently @subset will fail for a simple :col == X predicate if :col contains missing values. I think that for most users it might be preferable to have skipmissing set to true by default. Or failing that to allow a skipmissing option. There is of course the third option of the user writing something like ismissing(:col) ? false : :col == X, but that makes things more verbose

jkrumbiegel commented 3 years ago

you can use keywords with all macros, so @subset(df, :col == X; skipmissing = true) should work. It currently only works with the parentheses macro syntax because of the way parsing of keyword arguments works. And I've noticed that it doesn't currently work with Chain.jl when leaving out the first parameter, because the keyword arguments technically come before the positional arguments and I hadn't considered that at the time. I still want to add that to Chain.jl, though.

And maybe I'll put in a shortcut for skipmissing = true because I'm also annoyed by it, but I have to think that through first.

tobi-lipede-oodle commented 3 years ago

Ahh I see, thanks for the quick response! Yeah I was getting caught out when using the Chain.jl workflow. The following seems to work:

@subset(_, predicates...; kwargs...)
jkrumbiegel commented 3 years ago

Macro keyword arguments work now in Chain.jl https://github.com/jkrumbiegel/Chain.jl/pull/31

tobi-lipede-oodle commented 3 years ago

Oh wow awesome thanks!