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

Column names not feed through to named tuple.

Open Lincoln-Hannah opened this issue 4 years ago • 3 comments

@chain begin
    DataFrame(A=1, B=2)
    @rtransform  :X = (;:A , :B)  
end

Produces :X = (##1262 = 1, ##1263 = 2) Can it instead produce? :X = (A=1, B=2)

Lincoln-Hannah avatar Nov 10 '21 01:11 Lincoln-Hannah

This is not a DataFrames.jl related issue, so I am closing it.

The short answer is that you should write:

@rtransform(df, :X = (a=:A , b=:B))

But this is probably not something you are looking for. If you are not satisfied with it can you please re-open the issue in DataFramesMeta.jl (for some reason I am not able to transfer your issue).

However, in general, I do not think what you want is possible as (; A, B) syntax is resolved on parser level, and there are no A and B variables defined in the scope of @rtransform and there cannot be such variables defined - we need to use gensym to make sure we do not introduce conflicting variable names.

CC @pdeffebach

bkamins avatar Nov 10 '21 06:11 bkamins

I'm going to re-open to think about it some more. It's a reasonable request and maybe i can think of something. But I am pessimistic, given the fact that it's handled at the parser level.

pdeffebach avatar Nov 10 '21 14:11 pdeffebach

Ah - sorry for closing. For some reason I thought the issue was opened in DataFrames.jl. My bad. Of course it should be kept open here.

bkamins avatar Nov 10 '21 14:11 bkamins