Allow for keyword arguments
DataFrames.transform allows for keyword arguments. The current way @transform parses expressions does not allow for this.
Side note: this is a point for :x over x, but we definitely want to allow keyword arguments.
Update, this is actually very easy to do without deciding :x vs x.
I think this should go in before 1.0, and it should be the last thing we do before 1.0.
Proposal: With the normal function call syntax @transform(:x = 1; copycols = false). With the "block" syntax we have a @kwargs macro flag, which collects the keyword arguments as-is and passes them to the underlying functions.
With the "block" syntax we have a
@kwargsmacro flag
Can you please show an example?
- will this be allowed multiple times or a single time in block syntax?
- in any position or only at the end?
- how multiple kwargs would be separated?
- Also in call syntax - would it be allowed or not?
Other than that it looks reasonable
- will this be allowed multiple times or a single time in block syntax?
Only once, at the end.
- in any position or only at the end?
At the end
- how multiple kwargs would be separated?
I think I would have @kwargs(; a = 1, b = 2). Very heavy handed. But this will be for advanced users only.
- Also in call syntax - would it be allowed or not?
No. In call syntax they can just do @transform(df, ...; a = 1, b = 2).
So why do you need:
@kwargs(; a = 1, b = 2)
and not just e.g.:
@kwargs a = 1, b = 2
?
@kwargs a = 1, b = 2 parses weirdly, unfortunately
julia> macro kwargs(args...)
esc(kwargs_helper(args...))
end;
julia> function kwargs_helper(args...)
@show args
:()
end;
julia> @kwargs a = 1, b = 2
args = (:(a = ((1, b) = 2)),)
()
Then why not?
@kwarg a = 1
@kwarg b = 1
and allow it multiple times and require passing only one kwarg per line?
Having keyword arguments would be very helpful. I just reverted a bunch of my code from DataFramesMeta.jl to DataFrames.jl when I realized that I cannot use view=true on @subset or @rsubset, which was hurting performance.
Ah I'm sorry. I will try to finish this PR this week. It stalled due to a busy summer.