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

transform(df, :x => AsTable)` should probably work #2779

Closed
pdeffebach opened this issue Jun 5, 2021 · 1 comment · Fixed by #2780
Closed

transform(df, :x => AsTable)` should probably work #2779

pdeffebach opened this issue Jun 5, 2021 · 1 comment · Fixed by #2780
Milestone

Comments

@pdeffebach
Copy link
Contributor

I think the following should maybe work

julia> vnt = [(a = 1, b = (c = 2, d = 3)), (a = 4, b = (c = 5, d = 6))];

julia> df = DataFrame(vnt)
2×2 DataFrame
 Row │ a      b              
     │ Int64  NamedTup…      
─────┼───────────────────────
   1 │     1  (c = 2, d = 3)
   2 │     4  (c = 5, d = 6)

julia> transform(df, :b => AsTable)
2×3 DataFrame
 Row │ a      b               b_AsTable                         
     │ Int64  NamedTup…       AsTable                           
─────┼──────────────────────────────────────────────────────────
   1 │     1  (c = 2, d = 3)  AsTable(NamedTuple{(:c, :d), Tup…
   2 │     4  (c = 5, d = 6)  AsTable(NamedTuple{(:c, :d), Tup…

I think maybe this and transform(df, :b => [:x, :y]) should work, given that transform(df, :b => :bb) works.

@bkamins bkamins added the feature label Jun 5, 2021
@bkamins bkamins added this to the 1.x milestone Jun 5, 2021
@bkamins
Copy link
Member

bkamins commented Jun 5, 2021

It should be OK to add (and not too hard). It is consistent with the logic that :col1 => :col2 is rewritten as :col1 => identity => :col2. I will make a PR and we can discuss things there.

Since the syntax currently works I would classify it as a bug (as it is clearly unintended - it only works because AsTable is callable)

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

Successfully merging a pull request may close this issue.

2 participants