Because this is a multi-step approach it doesn’t work well with piping / Chain.jl, so it’s natural to introduce some kind of special macro solution for DataFrameMacros.jl v0.2. I’ve iterated back and forth on this and now decided on an optional @subset argument to @transform! and @select!. (The @subset expression by itself could not be executed without a DataFrame argument, so this only works within @transform! and @select!)
Yes multiple conditions are fine, same rules as for the normal @subset macro, that’s why I chose this form so it’s hopefully intuitive what’s allowed. Multiple @subset macros are not allowed currently, I didn’t think that option would help much.
It’s applied with ungroup = false so that the transform! call also acts on groups afterwards. Then the original grouped dataframe is returned so the result is still grouped.
Ah - now I see it in the docstring. It is a bit inconsistent as @transform! without @subset returns the data frame underlying GroupedDataFrame.
Why do you prefer to have a different behavior here?
If you wanted to ensure consistency I think the solution would be to add a single check at the beginning of a the macro if an AbstractDataFrame or GroupedDataFrame is passed and just store there what should be returned at the end.
Hm yeah I was unsure about this aspect actually, the difference is that I’m not returning the result of transform! because that wouldn’t have all the rows. So if I do ungroup manually, then I should divert the ungroup = false option that you could pass to the macro so that it disables my own ungrouping, it wouldn’t do anything in the transform! call itself. That also didn’t seem super clear to me, but maybe it’s the better choice?