Add docs and tests and site update for `ReducedGroupBy.into`
- Dominant language
- Kotlin
- Stars
- 1.1k
- Forks
- 83
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 30
Description
## Add docs and tests for `ReducedGroupBy.into`
`core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/into.kt` contains several `ReducedGroupBy.into` overloads without KDocs and without dedicated test coverage.
`GroupBy.into` is already documented better and has coverage, but `ReducedGroupBy.into` is a separate API path used after reducing groups with operations like `first`, `last`, `minBy`, `maxBy`, `medianBy`, or `percentileBy`.
### What it does
`ReducedGroupBy.into` transforms each reduced group row into a value or row-like result and writes it into a new column of the resulting `DataFrame`.
Examples:
```kotlin
df.groupBy { isHappy }
.minBy { age }
.into("youngest") { name }
df.groupBy("isHappy")
.minBy("age")
.into("youngest") { getColumnGroup("name") }
```
There is also a shortcut overload:
```kotlin
ReducedGroupBy.into(columnName: String)
```
which stores the reduced row itself into the target column.
### Scope
- Add concise KDocs for public `ReducedGroupBy.into` overloads in `into.kt`.
- Add dedicated unit tests for `ReducedGroupBy.into`.
- Improve the site docs with a clearer `ReducedGroupBy.into` example.
### Test scenarios as an option
- `groupBy(...).minBy(...).into("youngest") { name }` creates one row per group and stores computed values in the target column.
- `into("youngest") { getColumnGroup("name") }` stores a column group value from the reduced row.
- `into("row")` stores the whole reduced row in the target column.
- If a reducer returns no row for a group, the result handles it consistently with the current implementation.
### Suggested basic test
```kotlin
@Test
fun `reduced group by into stores value from reduced row`() {
val df = dataFrameOf("city", "name", "age")(
"London", "Alice", 30,
"London", "Bob", 20,
"Paris", "Charlie", 25,
)
val result = df
.groupBy("city")
.minBy("age")
.into("youngest") { "name"() }
result["city"].toList() shouldBe listOf("London", "Paris")
result["youngest"].toList() shouldBe listOf("Bob", "Charlie")
}
```
### Site docs placement
Add this to the existing `groupBy` page:
https://kotlin.github.io/dataframe/groupby.html
Recommended section:
- `## Reducing`
- `### Step 2: transform the result to a DataFrame`
- `#### Examples of transforming`
- `##### into`
The current page already has a short `into` mention there, so expand that subsection with a small input/output table and one runnable example.
### Acceptance criteria
- `ReducedGroupBy.into` overloads have KDocs.
- There are dedicated tests for value expression and whole-row `into(columnName)` behavior.
- The `groupBy` site page explains `ReducedGroupBy.into` separately from `GroupBy.into`.
- The docs include a small example with expected output.
Contributor guide
Assessment
This issue has not been assessed yet.