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

add astable macro #291

Closed
wants to merge 1 commit into from
Closed

add astable macro #291

wants to merge 1 commit into from

Conversation

pdeffebach
Copy link
Collaborator

Not yet ready for a review.

To simulate @t from DataFrameMacros

julia> df = DataFrame(a = rand(5), b = rand(5));

julia> @transform df @astable begin 
           :x = :b
           $"hello" = :a
       end
5×4 DataFrame
 Row │ a         b         x         hello    
     │ Float64   Float64   Float64   Float64  
─────┼────────────────────────────────────────
   1 │ 0.495296  0.788492  0.788492  0.495296
   2 │ 0.935795  0.895012  0.895012  0.935795
   3 │ 0.340286  0.32458   0.32458   0.340286
   4 │ 0.911353  0.585055  0.585055  0.911353
   5 │ 0.74855   0.655892  0.655892  0.74855

@pdeffebach
Copy link
Collaborator Author

A note on the API: As you may know I also maintain AddToField.jl with syntax

@addnt begin 
    @add x = 1
    @add y = 5
end

To make the named tuple (x = 1, y = 5).

This functionality is similar, but a bit more DataFrames specific. It allows for consistency by keeping :x and $x referring to columns in the DataFrame. We can't do that in an external macro because we need to treat the column identifiers on the LHS in a special way.

@pdeffebach
Copy link
Collaborator Author

Okay I'm thinking I will need to port over more of DataFrameMacros.jl's parsing code, in particular the stuff that uses MacroTools.postwalk. I will think more about this tomorrow.

@bkamins
Copy link
Member

bkamins commented Aug 23, 2021

Thank you for working on this!

@pdeffebach
Copy link
Collaborator Author

Closed in favor of #298

@pdeffebach pdeffebach closed this Sep 15, 2021
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

Successfully merging this pull request may close these issues.

None yet

2 participants