Skip to content

Split the Gradle and Kotlin build snippets for Android and Server-side #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 97 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
[![Maven Central](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/dataframe?color=blue&label=Maven%20Central)](https://search.maven.org/artifact/org.jetbrains.kotlinx/dataframe)
[![GitHub License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)

Kotlin Dataframe aims to reconcile Kotlin static typing with dynamic nature of data by utilizing both the full power of Kotlin language and opportunities provided by intermittent code execution in Jupyter notebooks and REPL.
Kotlin Dataframe aims to reconcile Kotlin's static typing with the dynamic nature of data by utilizing both the full power of the Kotlin language and the opportunities provided by intermittent code execution in Jupyter notebooks and REPL.

* **Hierarchical** — represents hierarchical data structures, such as JSON or a tree of JVM objects.
* **Functional** — data processing pipeline is organized in a chain of `DataFrame` transformation operations. Every operation returns a new instance of `DataFrame` reusing underlying storage wherever it's possible.
* **Readable** — data transformation operations are defined in DSL close to natural language.
* **Practical** — provides simple solutions for common problems and ability to perform complex tasks.
* **Practical** — provides simple solutions for common problems and the ability to perform complex tasks.
* **Minimalistic** — simple, yet powerful data model of three column kinds.
* **Interoperable** — convertable with Kotlin data classes and collections.
* **Generic** — can store objects of any type, not only numbers or strings.
Expand All @@ -23,23 +23,105 @@ Explore [**documentation**](https://kotlin.github.io/dataframe/overview.html) fo

## Setup

### Gradle
### Gradle for JVM
```groovy
// build.gradle

plugins {
// Optional Gradle plugin for enhanced type safety and schema generation
// https://kotlin.github.io/dataframe/gradle.html
id 'org.jetbrains.kotlinx.dataframe' version '0.10.1'
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.jetbrains.kotlinx:dataframe:0.10.1'
}
```

```kotlin
// build.gradle.kts

plugins {
// Optional Gradle plugin for enhanced type safety and schema generation
// https://kotlin.github.io/dataframe/gradle.html
id("org.jetbrains.kotlinx.dataframe") version "0.10.0"
id("org.jetbrains.kotlinx.dataframe") version "0.10.1"
}

repositories {
mavenCentral()
}

dependencies {
implementation("org.jetbrains.kotlinx:dataframe:0.10.0")
implementation("org.jetbrains.kotlinx:dataframe:0.10.1")
}
```

### Gradle for Android
```groovy
// build.gradle

plugins {
// Optional Gradle plugin for enhanced type safety and schema generation
// https://kotlin.github.io/dataframe/gradle.html
id 'org.jetbrains.kotlinx.dataframe' version '0.10.1'
}

dependencies {
implementation 'org.jetbrains.kotlinx:dataframe:0.10.1'
}

android {
defaultConfig {
minSdk 26 // Android O+
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
packagingOptions {
resources {
pickFirsts = ["META-INF/AL2.0",
"META-INF/LGPL2.1",
"META-INF/ASL-2.0.txt",
"META-INF/LICENSE.md",
"META-INF/NOTICE.md",
"META-INF/LGPL-3.0.txt"]
excludes = ["META-INF/kotlin-jupyter-libraries/libraries.json",
"META-INF/{INDEX.LIST,DEPENDENCIES}",
"{draftv3,draftv4}/schema",
"arrow-git.properties"]
}
}
}

// optional, could be required for KSP
tasks.withType(KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = '1.8'
}
}
```

```kotlin
// build.gradle.kts

plugins {
// Optional Gradle plugin for enhanced type safety and schema generation
// https://kotlin.github.io/dataframe/gradle.html
id("org.jetbrains.kotlinx.dataframe") version "0.10.1"
}

dependencies {
implementation("org.jetbrains.kotlinx:dataframe:0.10.1")
}

// Below only applies to Android projects
android {
defaultConfig {
minSdk = 26 // Android O+
Expand Down Expand Up @@ -70,10 +152,13 @@ android {
}
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {

// required for KSP
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
```

### Jupyter Notebook

Install [Kotlin kernel](https://github.com/Kotlin/kotlin-jupyter) for [Jupyter](https://jupyter.org/)
Expand All @@ -97,7 +182,7 @@ or specific version:

## Kotlin, Kotlin Jupyter, OpenAPI, Arrow and JDK versions

This table shows the mapping between main library components versions and minimum supported Java versions.
This table shows the mapping between main library component versions and minimum supported Java versions.

| Kotlin DataFrame Version | Minimum Java Version | Kotlin Version | Kotlin Jupyter Version | OpenAPI version | Apache Arrow version |
|--------------------------|----------------------|----------------|------------------------|-----------------|----------------------|
Expand All @@ -116,6 +201,9 @@ val airline by columnOf("KLM(!)", "{Air France} (12)", "(British Airways. )", "1

// create dataframe
val df = dataFrameOf(fromTo, flightNumber, recentDelays, airline)

// print dataframe
df.print()
```

**Clean:**
Expand Down Expand Up @@ -155,7 +243,7 @@ val clean = df
clean
// group by the flight origin renamed into "from"
.groupBy { origin named "from" }.aggregate {
// we are in the context of single data group
// we are in the context of a single data group

// total number of flights from origin
count() into "count"
Expand Down