Add docs and tests for `frames` pivot aggregation
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 1.1k
- Forks
- 83
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 30
Description
Add docs and tests for frames pivot aggregation
core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/frames.kt contains two small public APIs without KDocs and without dedicated unit tests:
Pivot<T>.frames(): DataRow<T>PivotGroupBy<T>.frames(): DataFrame<T>
The function is briefly mentioned on the pivot site page in the aggregation grammar and examples:
https://kotlin.github.io/dataframe/pivot.html#examples-of-aggregation
What it does
frames() aggregates pivot groups without reducing their rows. Each pivot key becomes a resulting column, and the corresponding grouped rows are stored as frame values.
For Pivot, the result is a DataRow.
For PivotGroupBy, the result is a DataFrame with one row per grouping key.
Scope
- Add concise KDocs for both
frames()overloads inframes.kt. - Add one basic unit test for
Pivot.frames(). - Improve the
pivotsite docs with a short explanation, input/output tables, and a runnable example forframes().
Suggested KDoc content
/**
* Aggregates this [Pivot] by keeping each pivot group as a frame.
*
* Each pivot key becomes a column in the resulting [DataRow], and each value is
* a [DataFrame] containing rows that belong to the corresponding pivot group.
*/
For PivotGroupBy.frames(), use the same idea but mention that the result is a DataFrame
with one row per grouping key.
Basic test scenario
- Given a dataframe with a Boolean pivot column, e.g.
isHappy. - When calling
df.pivot { isHappy }.frames(). - Then the result contains columns for pivot keys, e.g.
trueandfalse. - And each resulting value is a dataframe with rows belonging to that pivot group.
Test sketch
@Test
fun `pivot frames keeps pivot groups as frame values`() {
val df = dataFrameOf("name", "isHappy", "age")(
"Alice", true, 20,
"Bob", false, 30,
"Charlie", true, 40,
)
val result = df.pivot("isHappy").frames()
result.columnNames() shouldBe listOf("true", "false")
val happy = result["true"] as DataFrame<*>
val unhappy = result["false"] as DataFrame<*>
happy.rowsCount() shouldBe 2
unhappy.rowsCount() shouldBe 1
}
Acceptance criteria
Pivot.frames()andPivotGroupBy.frames()have KDocs.- There is at least one dedicated unit test for
frames(). - The pivot documentation includes a clear
frames()example with input/output tables.
Contributor guide
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 with core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/frames.kt and review the existing pivot aggregation tests before adding coverage for both pivot-key results and grouped frame values. Update the pivot site page at the aggregation examples section with the requested explanation, tables, and runnable example. Done means both overloads have KDocs, a dedicated unit test passes, and the site documentation includes a clear frames() example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- documentation, testing
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100