DataFramesMeta.jl icon indicating copy to clipboard operation
DataFramesMeta.jl copied to clipboard

Add a `@bycol` macro-flag

Open pdeffebach opened this issue 1 year ago • 5 comments

Can't believe this doesn't exist. I would really like it.

@MatthewRGonzalez do you want to make a PR?

pdeffebach avatar Mar 17 '23 18:03 pdeffebach

Sure-- I'll check this out @pdeffebach

MatthewRGonzalez avatar Mar 19 '23 22:03 MatthewRGonzalez

@MatthewRGonzalez I've marked this as 1.0.

I want to get a 1.0 release together soon. People are going to get mad if we do too many v0.x.0 releases. But I think this is a feature that should go into 1.0

pdeffebach avatar Apr 09 '23 18:04 pdeffebach

@pdeffebach Do you have any examples in mind for applications of the @bycol flag? Are you looking for something like:

@chain df begin
           transform(@bycol r"x" .=> mean)
       end

as opposed to

@chain df begin
           transform(Cols(r"x") .=> mean)
       end

MatthewRGonzalez avatar Apr 11 '23 19:04 MatthewRGonzalez

No, @bycol is the opposite of @byrow.

@transform df @bycol :y = f(:x)

gets lowered to

transform(df, :x => f => :y)

that is, it's redundant by itself. But if you have a block it matters

@rtransform df begin
    :z = g(:a)
    @bycol :y = f(:x)
end

gets lowered to

transform(df, 
    :a => ByRow(g) => :z,
    :x => f => :y)

pdeffebach avatar Apr 11 '23 21:04 pdeffebach

Got it-- I'll start working!

MatthewRGonzalez avatar Apr 13 '23 20:04 MatthewRGonzalez