Add @subset#263
Conversation
|
Okay, I've made All docs are added and tests added and pass. So this could be merged. |
nalimilan
left a comment
There was a problem hiding this comment.
Thanks! That makes the API much more consistent with DataFrames.
Regarding skipmissing, I think it would be good to outline a general plan. Should DataFramesMeta automatically skip/propagate missing values everywhere? We discussed adding a keyword argument to do that in DataFrames at JuliaData/DataFrames.jl#2314. It hasn't been implemented at this point, but it would make sense to decide whether we would like to enable it by default eventually in DataFramesMeta.
| create_args_vector(arg) -> vec, wrap_byrow | ||
|
|
||
| Normalize a single input to a vector of expressions, | ||
| with a `wrap_byrow` flag indicating that the | ||
| expressions should operate by row. | ||
|
|
||
| If `arg` is a single `:block`, it is unnested. | ||
| Otherwise, return a single-element array. | ||
| Also removes line numbers. | ||
|
|
||
| If `arg` is of the form `@byrow ...`, then | ||
| `wrap_byrow` is returned as `true`. | ||
| create_args_vector(arg) -> vec, outer_flags |
There was a problem hiding this comment.
Why remove the contents of the docstring?
There was a problem hiding this comment.
I will add a correct docstring.
| @@ -763,13 +705,13 @@ end | |||
| @test nrow(d) == 1 | |||
|
|
|||
| d = @where df begin | |||
| @@ -0,0 +1,143 @@ | |||
| module TestSubset | |||
There was a problem hiding this comment.
Can you add tests with GroupedDataFrame?
There was a problem hiding this comment.
added, ported from @where.
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
|
w.r.t. I think that adding I think something along the lines of This PR in Missings.jl is the solution. Since we are constructing anonymous functions we can just add a That's a long term strategy. Maybe in the meantime we should just continue to treat |
| end | ||
|
|
||
| end # module No newline at end of file | ||
| @testset "@subset with a grouped data frame" begin |
There was a problem hiding this comment.
Also test @subset! with GroupedDataFrame?
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
|
Okay ready for merging. |
|
Thank you! |
This is an initial attempt to add
@subset.I was able to entirely replace
@whereby callingskipmissing=trueas a keyword argument, which is great.We are in a real bind with regards to keyword arguments. With the move to using
:blockwe can't just support keyword argument handling like@subset(df, ...; skipmissing = true). So I added the flag@skipmissingand re-factored the macro-flags a little bit.But adding tests is still a pain, because the tests have
missingso we would have to add@skipmissingeverywhere. Is this a time when we should break with the DataFrames API and makeskipmissing=truethe default? That would make people's lives a bit easier when upgrading from@whereto@subset.@nalimilan This is a design decision, so I would appreciate your input.