-
Notifications
You must be signed in to change notification settings - Fork 3
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
@_ within the selector Fun part of DataFrames.select #16
Comments
@_ ByRow(_1 + _2) # equiv. ByRow(+), or ByRow((_1,_2) -> _1 + _2) The second one is harder, I think what you want is |
Exactly, thanks Michael. The new In the "True spirit of Underscores.jl", it's df1 = @_ select(df, Not(:b) => ByRow(_1 + _2))
df2 = @_ select(df, :a =>_ .^2) But unfortunately this doesn't seem possible(?) because I do wonder whether there's any way to resolve this, or whether DataFrames syntax is just too specialized for this to work in a general way. |
I suppose it wouldn't be impossible to special-case @_ fun(x, :a =>_ .^2) # fun(x, ξ -> (:a => ξ.^2)) But it is one more rule to know, which makes xref #12 for thinking about the rules. |
Certainly, but I feel like there's cases where having a closure which returns a pair might be desired. I don't have a very natural example, but I feel like it would be weird if the following didn't work: julia> @_ map(_=>_^2+1, 1:3) |> Dict
Dict{Int64,Int64} with 3 entries:
2 => 5
3 => 10
1 => 2 This isn't exactly the syntax above, and I suppose we could go to extra lengths to pattern match things which "happen to look like" DataFrames usage. But overall I feel like that will lead to trouble :) |
Ah that's a good example, someone will do that for sure. Maybe the place for a macro which understands the special syntax used with DataFrames, is DataFrames. It's possible that a |
I agree that's for the best. I'd be quite happy to generalize the functions which do the |
It seems currently @_ not working in the following:
The text was updated successfully, but these errors were encountered: