mcabbott / mcabbott/AxisKeys.jl

Feature request: aggregation function for wrapdims (and populate!)

Open
#107 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.