JuliaData / JuliaData/DataFrames.jl

Rules for allowed return value in combine

Open
#2,133 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

breaking decision
Dominant language
Julia
Stars
1.8k
Forks
372
Avg merge
5d 7h
Merged PRs (30d)
5

Description

Currently we have:

julia> df = DataFrame(rand(2,2))
2×2 DataFrame
│ Row │ x1      │ x2        │
│     │ Float64 │ Float64   │
├─────┼─────────┼───────────┤
│ 1   │ 0.59547 │ 0.0618626 │
│ 2   │ 0.70438 │ 0.0882641 │

julia> by(df, :x1, z = :x1 => x -> rand(1,1,1))
2×2 DataFrame
│ Row │ x1      │ z          │
│     │ Float64 │ Array…     │
├─────┼─────────┼────────────┤
│ 1   │ 0.59547 │ [0.815674] │
│ 2   │ 0.70438 │ [0.603017] │

julia> by(df, :x1, z = :x1 => x -> rand(1,1))
ERROR: ArgumentError: a single value or vector result is required when passing a vector or tuple of functions (got Array{Float64,2})

This is due to the rule in:
https://github.com/JuliaData/DataFrames.jl/blob/master/src/groupeddataframe/splitapplycombine.jl#L709

I am not 100% this rule is good. I understand the original reason of disallowing them, but it seems that in Pair context it is not ambiguous and we do not need this exception.

@nalimilan - what is your opinion on thins (this is related to select design where I will post a related comment soon)

Contributor guide

Open the contributing guide

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 in src/groupeddataframe/splitapplycombine.jl around line 709 and reproduce the two Julia examples from the issue. Determine and document whether Pair results should allow matrix-valued outputs without ambiguity; the work is done when the allowed return-value rule and its behavior are agreed and covered by appropriate tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.