Skip to content
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

Column names not feed through to named tuple. #306

Open
Lincoln-Hannah opened this issue Nov 10, 2021 · 3 comments
Open

Column names not feed through to named tuple. #306

Lincoln-Hannah opened this issue Nov 10, 2021 · 3 comments

Comments

@Lincoln-Hannah
Copy link

Lincoln-Hannah commented Nov 10, 2021

@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)

@bkamins
Copy link
Member

bkamins commented Nov 10, 2021

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 bkamins closed this as completed Nov 10, 2021
@pdeffebach pdeffebach reopened this Nov 10, 2021
@pdeffebach
Copy link
Collaborator

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.

@bkamins
Copy link
Member

bkamins commented Nov 10, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants