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 across etc. for easier working with multiple columns #296

Open
pdeffebach opened this issue Sep 9, 2021 · 4 comments
Open

Add across etc. for easier working with multiple columns #296

pdeffebach opened this issue Sep 9, 2021 · 4 comments

Comments

@pdeffebach
Copy link
Collaborator

As referenced on discourse, lots of users have trouble with complicated source => fun => dest pairs. Maybe something like R's across might be useful.

It could live here. It could also live in a 3rd package that we re-export, like Chain.jl.

@bkamins
Copy link
Member

bkamins commented Sep 9, 2021

The question is if the problem is that we should add across or instead of using broadcasting (which is nice, clean, but maybe too magical) start promoting using a comprehension instead?

The only challenge is what while Not(:x) .=> fun will soon work [n => fun for n in Not(:x)] is impossible to be made working, so maybe indeed @across within DataFramesMeta.jl that would be data-frame context sensitive (rewriting Not(:x) etc. as appropriate) would make sense?

@nalimilan
Copy link
Member

As I said at JuliaData/DataFrames.jl#2870 I'd rather wait a bit after Between, All, Cols and Not support .=> before deciding whether adding across would really make people's life easier. I'm concerned that people find across natural simply because they are used to it.

@pdeffebach
Copy link
Collaborator Author

I agree. I think we can make a lot of progress helping people ease into src => fun => dest. If that approach remains too hard after tutorials / community knowledge etc, then we can consider across.

@xiaodaigh
Copy link
Contributor

using DataFrames, DataFrameMacros


df = DataFrame(a = 1:3)

function return2(a)
  (a = a/2, b = a/3)
end
transform(df, :a =>  return2 => [:c, :d])

The above return2 function returns 2 columns which I'd like to assign to two new columns. I don't it's possible currently with this package.

Wish we can do something there.

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

4 participants