Assign to multiple columns in `@transform` (and other applicables)
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start with the existing @rtransform! and @astable entry points, and compare their behavior with DataFrames' transform! multiple-column assignment shown in the issue. Determine whether the concise @astable assignments can support tuple or iterable expansion to multiple target columns; done means both examples work as described.
Written by the indexing model from the issue text.
Description
In DataFrames proper I can do something like
df = DataFrame(point = [(1, 2), (2, 3), (3, 4)])
transform!(df, :point => [:x, :y])
transform!(df, [:x, :y] => ByRow((x, y) -> expensive_computation(x, y)) => [:res1, :res2])
which automatically expands the returned iterable onto two new columns. As far as I can see, this would map to
df = DataFrame(point = [(1, 2), (2, 3), (3, 4)])
@rtransform!(df, [:x, :y]=:point)
@rtransform!(df, [:res1, :res2]=expensive_computation(:x,:y))
in DataFramesMeta, however, this does not seem to be currently possible.
It is possible to fuse these operations with @astable:
df = DataFrame(point = [(1, 2), (2, 3), (3, 4)])
@rtransform!(df, @astable begin
:x = :point[1]
:y = :point[2]
intermediate = expensive_computation(:x, :y)
:res1 = intermediate[1]
:res2 = intermediate[2]
end)
but then again, being able to write this as
@rtransform!(df, @astable begin
:x, :y = :point
:res1, :res2 = expensive_computation(:x, :y)
end)
Would be much more concise. Is there a reason that this behaviour is not implemented?
- Dominant language
- Julia
- Stars
- 495
- Forks
- 56
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JuliaData/DataFramesMeta.jl
-
New release?Open
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
JuliaData/DataFramesMeta.jl#430 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
JuliaData/DataFramesMeta.jl#428 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
JuliaData/DataFramesMeta.jl#416 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
JuliaData/DataFramesMeta.jl#407 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
JuliaData/DataFramesMeta.jl#394 · 5 comments ·
All issues in JuliaData/DataFramesMeta.jl
Similar issues
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
JuliaDiff/ChainRules.jl#871 · 1 comment ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
JuliaStats/LogExpFunctions.jl#134 · 2 comments ·
-
code bug PowerSystems 6.0
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Sienna-Platform/PowerSystems.jl#1849 ·
Maintainers usually reply within 7 days