Skip to content
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

Keyword Argument Not Working for @rsubset #344

Closed
Ethan-Russell opened this issue Nov 18, 2022 · 6 comments
Closed

Keyword Argument Not Working for @rsubset #344

Ethan-Russell opened this issue Nov 18, 2022 · 6 comments

Comments

@Ethan-Russell
Copy link

I'm running into an issue with @rsubset not passing through the view=true keyword argument in the way that I would expect. Here's a MWE:

julia> df = DataFrame(x=rand(4))
4×1 DataFrame
 Row │ x
     │ Float64   
─────┼───────────
   10.0970303
   20.436719
   30.165089
   40.505097

julia> subset(df, :x=>ByRow(x->x>0.5), view=true)
1×1 SubDataFrame
 Row │ x        
     │ Float64  
─────┼──────────
   10.505097

julia> DataFramesMeta.@rsubset(df, :x>0.5, view=true)
1×1 DataFrame
 Row │ x        
     │ Float64  
─────┼──────────
   10.505097

You can see above that @rsubset returns a DataFrame rather than a SubDataFrame as I would expect

@pdeffebach
Copy link
Collaborator

Yes. This is expected behavior. Keyword arguments were added in #323 , but we haven't made a release yet.

Note, your code is actually just saying "keep all rows" in the 2nd argument, so it is doing something just not what you think its doing.

@Ethan-Russell
Copy link
Author

Thanks for the quick response. Good to know - I will look out for the next release.

I'm not sure that I'm tracking - how is my code saying to keep all the rows in the second argument? Isn't it only keeping the rows in which x>0.5?

@pdeffebach
Copy link
Collaborator

Sorry, multiple arguments are "and"-ed.

So the first argument says "keep all rows in which :x > .5" and the second one says "keep all rows". The intersection of those two conditions is to just keep all rows with :x > .5.

@Ethan-Russell
Copy link
Author

Ah, I see - so currently the view=true keyword argument is being parsed as an argument, which is keeping all rows?

@pdeffebach
Copy link
Collaborator

yes exactly.

@Ethan-Russell
Copy link
Author

Thanks! Closing since this is intended behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants