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

Unexpected output from @combine when used in Lazy:@> #217

Closed
dbuffoni opened this issue Dec 19, 2020 · 2 comments
Closed

Unexpected output from @combine when used in Lazy:@> #217

dbuffoni opened this issue Dec 19, 2020 · 2 comments

Comments

@dbuffoni
Copy link

Hi,
Apparently @combine seems to provide an unexpected result when used in a @> pipe after a transform.

Please review the following test:

`using DataFrames, DataFramesMeta
using Lazy: @>

df = DataFrame(a = [1, 1, 2, 2], b = [1, 3, 8, 10])
@> begin
groupby(df, :a)
#@Transform(c = :b.+1)
@combine(m=sum(:b))
end`

which correctly returns

2×2 DataFrame │ Row │ a │ m │ │ 1 │ 1 │ 4 │ │ 2 │ 2 │ 18 │

while uncommenting the @Transform the groups are lost and the entire block returns a single row

1×1 DataFrame │ Row │ m │ │ 1 │ 22 │

Is this expected? the workaround would be using 'by' instead of 'combine'

@pdeffebach
Copy link
Collaborator

Thanks for the issue report!

This is indeed expected. By default DataFrames.transform "ungroups" he data after the transformation. Fixing #179 to allow keyword arguments is the solution. Eventually it would be nice to do

@transform(m = sum(:b); ungroup = false)

which would allow grouping to be preserved in the pipe.

But this has no been added yet, unfortunately.

@dbuffoni
Copy link
Author

Great, thank you for your explanation

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

2 participants