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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

huangyxi
Copy link

@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)

@bkamins bkamins modified the milestones: 1.7, 1.x Sep 14, 2024
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.

2 participants