Java Clean Architecture Masterclass

Java Clean Architecture MasterclassNov 20-21

Join

Kotlin DataFrame: typesafe in-memory structured data processing for JVM

JetBrains incubator project Kotlin component beta stability Kotlin Dynamic XML Badge Dynamic XML Badge GitHub License Binder

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.

Integrates with Kotlin Notebook. Inspired by krangl, Kotlin Collections and pandas

🚀 Quickstart

Looking for a fast and simple way to learn the basics?
Get started in minutes with our Quickstart Guide.

It walks you through the core features of Kotlin DataFrame with minimal setup and clear examples — perfect for getting up to speed in just a few minutes.

quickstart_preview

Documentation

Explore documentation for details.

You could find the following articles there:

What's new

1.0.0-Beta2: Release notes

Check out this notebook with new features in v0.15.

Setup

For more detailed instructions on how to get started with Kotlin DataFrame, refer to the Getting Started.

Kotlin Notebook

You can use Kotlin DataFrame in Kotlin Notebook, or other interactive environment with Kotlin Jupyter Kernel support, such as Datalore, and Jupyter Notebook.

You can include all the necessary dependencies and imports in the notebook using line magic:

%use dataframe

You can use %useLatestDescriptors to get the latest stable version without updating the Kotlin kernel:

%useLatestDescriptors
%use dataframe

Or manually specify the version:

%use dataframe($dataframe_version)

Refer to the Get started with Kotlin DataFrame in Kotlin Notebook for details.

Gradle

Add dependencies in the build.gradle.kts script:

dependencies {
    implementation("org.jetbrains.kotlinx:dataframe:1.0.0-Beta2")
}

Make sure that you have mavenCentral() in the list of repositories:

repositories {
    mavenCentral()
}

Refer to the Get started with Kotlin DataFrame on Gradle for details. Also, check out the custom setup page if you don't need some formats as dependencies, for Groovy, and for configurations specific to Android projects.

Code example

This example of Kotlin DataFrame code with the Compiler Plugin enabled. See the full project. See also this example in Kotlin Notebook.

val df = DataFrame
   // Read DataFrame from the CSV file.
   .readCsv("https://raw.githubusercontent.com/Kotlin/dataframe/master/data/jetbrains_repositories.csv")
   // And convert it to match the `Repositories` schema.
   .convertTo<Repositories>()

// Update the DataFrame.
val reposUpdated = repos
   // Rename columns to CamelCase.
   .renameToCamelCase()
   // Rename "stargazersCount" column to "stars".
   .rename { stargazersCount }.into("stars")
   // Filter by the number of stars:
   .filter { stars > 50 }
   // Convert values in the "topic" column (which were `String` initially)
   // to the list of topics.
   .convert { topics }.with { 
       val inner = it.removeSurrounding("[", "]")
        if (inner.isEmpty()) emptyList() else inner.split(',').map(String::trim)
   }
   // Add a new column with the number of topics.
   .add("topicCount") { topics.size }

// Write the updated DataFrame to a CSV file.
reposUpdated.writeCsv("jetbrains_repositories_new.csv")

Explore more examples here.

Data model

Visualizations

Kandy plotting library provides seamless visualizations for your dataframes.

kandy_preview

Kotlin, Kotlin Jupyter, Arrow, and JDK 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 Apache Arrow version
0.10.0 8 1.8.20 0.11.0-358 11.0.0
0.10.1 8 1.8.20 0.11.0-358 11.0.0
0.11.0 8 1.8.20 0.11.0-358 11.0.0
0.11.1 8 1.8.20 0.11.0-358 11.0.0
0.12.0 8 1.9.0 0.11.0-358 11.0.0
0.12.1 8 1.9.0 0.11.0-358 11.0.0
0.13.1 8 1.9.22 0.12.0-139 15.0.0
0.14.1 8 2.0.20 0.12.0-139 17.0.0
0.15.0 8 2.0.20 0.12.0-139 18.1.0
1.0.0-Beta2 8 / 11 2.0.20 0.12.0-383 18.1.0

Code of Conduct

This project and the corresponding community are governed by the JetBrains Open Source and Community Code of Conduct. Please make sure you read it.

License

Kotlin DataFrame is licensed under the Apache 2.0 License.

Join libs.tech

...and unlock some superpowers

GitHub

We won't share your data with anyone else.