apache / apache/datafusion

Add `pivot` & `unpivot` (melt) to DataFrame

Open
#12,907 6 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Is your feature request related to a problem or challenge?

Pivoting and unpivoting is a common use case for data scientists, this is currently missing in the DF api.

### Describe the solution you'd like

Add two methods to DataFrame struct:
- pivot
- possibility to add distinct values in advance (would be optimized into groupby.agg() directly)
- let DataFusion calculate distinct values automatically
- unpivot

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating the DataFrame struct and its existing groupby.agg() API, then review how DataFusion currently handles distinct values. Define the expected pivot and unpivot behavior, including supplied versus automatically calculated distinct values; done means both methods are available through the DataFrame API with appropriate coverage for those cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
data-engineering
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.