https://github.com/holgerbrandl/kdfutils
Misc utilities for kotlin-dataframe
https://github.com/holgerbrandl/kdfutils
Last synced: 3 months ago
JSON representation
Misc utilities for kotlin-dataframe
- Host: GitHub
- URL: https://github.com/holgerbrandl/kdfutils
- Owner: holgerbrandl
- License: mit
- Created: 2022-08-28T10:29:33.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-09T11:51:22.000Z (11 months ago)
- Last Synced: 2024-11-09T12:30:50.336Z (11 months ago)
- Language: Kotlin
- Size: 191 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changes.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# kdfutils
[  ](https://mvnrepository.com/artifact/com.github.holgerbrandl/kdutils) [](https://github.com/holgerbrandl/kdutils/actions?query=workflow%3Abuild) [](https://gitter.im/holgerbrandl/kdutils?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
> Misc utilities for kotlin-dataframe
An opinionated set of utilities that we loved in [krangl](https://github.com/holgerbrandl/krangl) are yet/initially/by-design missing in [kotlin-dataframe](https://github.com/Kotlin/dataframe)
### Example datasets
KDF lacks example data to produce reproducible examples
```kotlin
import org.jetbrains.kotlinx.dataframe.datasetsirisData.head()
sleepData.count()
flightsdata.columnNames()
```### Bidirectional conversion between krangl and kotlin-dataframe
```kotlin
irisData.toKotlinDF().toKranglDF()
```
Note: `kdfutils` does not have a runtme dependency on krangl. It's up to the user to add it if bi-directional conversion is needed### Extended unfold support
KDF supports an API to unfold object columns. However, as it still lacks some convenience, here we support of properties from object column with more control over the unfolding process (optionally keep original column, cherry which attributes to unfold, add prefix)
```kotlin
data class City(val name:String, val code:Int)
data class Person(val name:String, val address:City)val persons : List = listOf(
Person("Max", City("Dresden", 12309)),
Person("Anna", City("Berlin", 10115))
)val personsDF: DataFrame = persons.asDataFrame()
personsDF.unfold("address")// or selectively via property reference
personsDF.unfold("address", properties= listOf(City::name), keep = true, addPrefix = true )
```### Naming Conventions & Conversions
There are many ways to name columns. To ease the transition (between camel, snake, ..) and to create names complying with compiler conventions, this library provides some renaming utilities
Typically, this works best by first renaming columns to camel case
## Gradle
To get started, simply add it as a dependency:
```
dependencies {
implementation "com.github.holgerbrandl:kdfutils:1.4.5"
}
```
Note that kdfutils does not depend on `krangl` any longerBuilds are hosted on [maven-central](https://search.maven.org/search?q=a:kdfutils) supported by the great folks at [sonatype](https://www.sonatype.com/).