Provide replacement API for dataFrameOf("col", "col1").random* builders
- Dominant language
- Kotlin
- Stars
- 1.1k
- Forks
- 83
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 30
Description
Now we have a bunch of factory functions in DataFrameBuilder class:
`dataFrameOf("a", "b").randomInt()` or `dataFrameOf("a", "b").fill { }`
A few reasons i see this API problematic:
1. Not composable - it's not possible to create a dataframe of multiple different random columns
2. Not generic - it'd require special compiler plugin support for each functions. It would be quite trivial, but we have more robust dataframe factory:
```kt
dataFrameOf(
"a" to columnOf(...),
"b" to columnof(...),
)
```
So as a replacement we could try to rework API to leverage this constructor and enable arbitrary column generator functions:
```kt
val builder = ColumnBuilder(rows = 100)
dataFrameOf(
"a" to builder.randomInt(0..10),
"b" to builder.fill { it -> "myCustomGenerator$it" },
)
```
In which case compiler plugin supported will be possible without any changes there.
We would miss a few cases, that were used in examples:
`dataFrameOf('a'..'z').randomInt()`
And then there's a special case of dataframe builder:
```kt
public inline fun dataFrameOf(header: Iterable, fill: (T) -> Iterable): DataFrame<*>
dataFrameOf(1..10) { x -> (1..10).map { x * it } }
```
Maybe we should just keep it specifically.
Contributor guide
Assessment
This issue has not been assessed yet.