mcabbott / mcabbott/AxisKeys.jl
Feature request: aggregation function for wrapdims (and populate!)
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 154
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Description
This is basically what pandas.pivot_table does. Here's a naive implementation. I imagine this could be done more efficiently though.
julia> function wrap_reduce(df, aggregator, val, keys...)
grp = groupby(df, collect(keys))
agg = combine(grp, val => aggregator => :_val)
wrapdims(agg, :_val, keys...)
end
julia> df = DataFrame([
1 1
1 1
1 2
2 3
2 5
], ["x", "y"])
julia> wrap_reduce(df, sum, :y, :x)
1-dimensional KeyedArray(NamedDimsArray(...)) with keys:
↓ x ∈ 2-element Vector{Int64}
And data, 2-element Vector{Int64}:
(1) 4
(2) 8
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start by reading the existing wrapdims and populate APIs, then compare their behavior with the provided wrap_reduce example and the pandas.pivot_table reference. The work is complete when an aggregation function supports the demonstrated grouping and produces the expected keyed result, with an efficient approach identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100