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

docs for aggregation over grouped array-like elements #3425

Merged
merged 3 commits into from
Mar 20, 2025

Conversation

huangyxi
Copy link
Contributor

@huangyxi huangyxi commented Jan 31, 2024

Demonstrate how to aggregate over grouped array-like elements. (#3424)

julia> df = DataFrame(a=[1, 1, 2, 2],
                      b=[[1, 2], [2, 3], [3, 4], [4, 5]])
4×2 DataFrame
 Row │ a      b
     │ Int64  Array
─────┼───────────────
   11  [1, 2]
   21  [2, 3]
   32  [3, 4]
   42  [4, 5]

julia> gd = groupby(df, :a)
GroupedDataFrame with 2 groups based on key: a
First Group (2 rows): a = 1
 Row │ a      b
     │ Int64  Array
─────┼───────────────
   11  [1, 2]
   21  [2, 3]

Last Group (2 rows): a = 2
 Row │ a      b
     │ Int64  Array
─────┼───────────────
   12  [3, 4]
   22  [4, 5]

julia> combine(gd, :b => Refsum)
2×2 DataFrame
 Row │ a      b_Ref_sum
     │ Int64  Array
─────┼──────────────────
   11  [3, 5]
   22  [7, 9]

@huangyxi huangyxi changed the title docs for aggregation over grouped array-like elements (#3424) docs for aggregation over grouped array-like elements #3424 Jan 31, 2024
@huangyxi huangyxi changed the title docs for aggregation over grouped array-like elements #3424 docs for aggregation over grouped array-like elements Jan 31, 2024
@bkamins bkamins added the doc label Jan 31, 2024
@bkamins bkamins added this to the 1.7 milestone Jan 31, 2024
@@ -1665,6 +1665,22 @@ julia> combine(gd, :, AsTable(Not(:a)) => sum, renamecols=false)
7 │ 4 1 4 5
8 │ 4 1 8 9
```

# aggregation over array-like elements
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not aggregation specific. @nalimilan - what would be the best comment here?
Maybe:

# protecting vectors returned from a function from being expanded into multiple rows

(but it seems long, but maybe it is OK)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nalimilan, do you have any suggestions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is explicit enough?

# protecting returned vectors from being expanded into multiple rows

@bkamins bkamins modified the milestones: 1.7, 1.x Sep 14, 2024
@huangyxi huangyxi requested a review from bkamins March 20, 2025 07:42
@bkamins bkamins merged commit 900d016 into JuliaData:main Mar 20, 2025
7 of 8 checks passed
@bkamins
Copy link
Member

bkamins commented Mar 20, 2025

Thank you!

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

Successfully merging this pull request may close these issues.

3 participants