-
Notifications
You must be signed in to change notification settings - Fork 56
Add @subset
#263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove the contents of the docstring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add a correct docstring.
test/dataframes.jl
Outdated
|
|
||
| @test nrow(d) == 1 | ||
|
|
||
| d = @where df begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to deprecated.jl?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved.
| @@ -0,0 +1,143 @@ | |||
| module TestSubset | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add tests with GroupedDataFrame?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added, ported from @where.
Co-authored-by: Milan Bouchet-Valat <[email protected]>
Co-authored-by: Milan Bouchet-Valat <[email protected]>
Co-authored-by: Milan Bouchet-Valat <[email protected]>
|
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 | ||
| @testset "@subset with a grouped data frame" begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also test @subset! with GroupedDataFrame?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added!
Co-authored-by: Milan Bouchet-Valat <[email protected]>
Co-authored-by: Milan Bouchet-Valat <[email protected]>
|
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.