From 858157b59a83d7345bb4f4e2631c7ea9c0f5335c Mon Sep 17 00:00:00 2001 From: "andrei.kislitsyn" Date: Thu, 12 Jun 2025 15:57:19 +0400 Subject: [PATCH 1/3] readme example --- README.md | 58 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 09370b8cd..046e8f16f 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,24 @@ Kotlin DataFrame aims to reconcile Kotlin's static typing with the dynamic natur Integrates with [Kotlin kernel for Jupyter](https://github.com/Kotlin/kotlin-jupyter). Inspired by [krangl](https://github.com/holgerbrandl/krangl), Kotlin Collections and [pandas](https://pandas.pydata.org/) +## 🚀 Quickstart + +Looking for a fast and simple way to learn the basics? +Get started in minutes with our [Quickstart Guide](https://kotlin.github.io/dataframe/quickstart.html). + +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](docs/StardustDocs/images/guides/quickstart_preview.png) + + ## Documentation Explore [**documentation**](https://kotlin.github.io/dataframe) for details. You could find the following articles there: +* [Guides and Examples](https://kotlin.github.io/dataframe/guides-and-examples.html) * [Get started with Kotlin DataFrame](https://kotlin.github.io/dataframe/gettingstarted.html) * [Working with Data Schemas](https://kotlin.github.io/dataframe/schemas.html) * [Setup compiler plugin in Gradle project](https://kotlin.github.io/dataframe/compiler-plugin.html) @@ -56,21 +68,39 @@ for Groovy, and for configurations specific to Android projects. ## Code example ```kotlin -import org.jetbrains.kotlinx.dataframe.* -import org.jetbrains.kotlinx.dataframe.api.* -import org.jetbrains.kotlinx.dataframe.io.* +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() + + // Let's update the DataFrame with some operations using these features. + val reposUpdated = repos + // Rename columns to CamelCase. + // Note that after that, in the following operations, extension properties will have + // new names corresponding to the column names. + .renameToCamelCase() + // Rename "stargazersCount" column to "stars". + .rename { stargazersCount }.into("stars") + // And we can immediately use the updated name in the filtering. + .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) + } + // Now "topics" is a `List` column. + // Add a new column with the number of topics. + .add("topicCount") { topics.size } + // Add a new column with the kind of repository. + .add("kind") { getKind(fullName, topics) } + + // Write the updated DataFrame to a CSV file. + reposUpdated.writeCsv("jetbrains_repositories_new.csv") ``` -```kotlin -val df = DataFrame.read("https://raw.githubusercontent.com/Kotlin/dataframe/master/data/jetbrains_repositories.csv") -df["full_name"][0] // Indexing https://kotlin.github.io/dataframe/access.html - -df.filter { "stargazers_count"() > 50 }.print() -``` - -## Getting started in Kotlin Notebook - -Follow this [guide](https://kotlin.github.io/dataframe/gettingstartedkotlinnotebook.html) +Explore [**more examples here**](https://kotlin.github.io/dataframe/guides-and-examples.html). ## Data model * `DataFrame` is a list of columns with equal sizes and distinct names. @@ -79,8 +109,6 @@ Follow this [guide](https://kotlin.github.io/dataframe/gettingstartedkotlinnoteb * `ColumnGroup` — contains columns * `FrameColumn` — contains dataframes -Explore [**more examples here**](https://kotlin.github.io/dataframe/guides-and-examples.html). - ## Kotlin, Kotlin Jupyter, Arrow, and JDK versions This table shows the mapping between main library component versions and minimum supported Java versions. From d0293f8ebbd0c9cfedc310bca3dcb9ce49598703 Mon Sep 17 00:00:00 2001 From: "andrei.kislitsyn" Date: Thu, 12 Jun 2025 18:16:54 +0400 Subject: [PATCH 2/3] update readme --- README.md | 85 +- examples/notebooks/readme_example.ipynb | 2111 +++++++++++++++++++++++ 2 files changed, 2183 insertions(+), 13 deletions(-) create mode 100644 examples/notebooks/readme_example.ipynb diff --git a/README.md b/README.md index 046e8f16f..6a739e8f1 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,6 @@ It walks you through the core features of Kotlin DataFrame with minimal setup an ![quickstart_preview](docs/StardustDocs/images/guides/quickstart_preview.png) - ## Documentation Explore [**documentation**](https://kotlin.github.io/dataframe) for details. @@ -58,15 +57,73 @@ Check out this [notebook with new features](examples/notebooks/feature_overviews ## Setup +> For more detailed instructions on how to get started with Kotlin DataFrame, refer to the +> [Getting Started](https://kotlin.github.io/dataframe/gettingstarted.html). + +### Kotlin Notebook + +You can use Kotlin DataFrame in [Kotlin Notebook](https://plugins.jetbrains.com/plugin/16340-kotlin-notebook), +or other interactive environment with Kotlin Jupyter Kernel support, such as +[Datalore](https://datalore.jetbrains.com/), +and [Kotlin Jupyter](https://github.com/Kotlin/kotlin-jupyter). + +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](https://kotlin.github.io/dataframe/gettingstartedkotlinnotebook.html) +for details. + +### Gradle + +Add dependencies in the build.gradle.kts script: + ```kotlin -implementation("org.jetbrains.kotlinx:dataframe:1.0.0-Beta2") +dependencies { + implementation("org.jetbrains.kotlinx:dataframe:1.0.0-Beta2") +} ``` -Check out the [custom setup page](https://kotlin.github.io/dataframe/gettingstartedgradleadvanced.html) if you don't need some of the formats as dependencies, +Make sure that you have `mavenCentral()` in the list of repositories: + +```kotlin +repositories { + mavenCentral() +} +``` + +Refer to the +[Get started with Kotlin DataFrame on Gradle](https://kotlin.github.io/dataframe/gettingstartedgradle.html) +for details. +Also, check out the [custom setup page](https://kotlin.github.io/dataframe/gettingstartedgradleadvanced.html) +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](https://kotlin.github.io/dataframe/compiler-plugin.html) enabled. +See [the full project](https://github.com/Kotlin/dataframe/tree/master/examples/kotlin-dataframe-plugin-example). +See also +[this example in Kotlin Notebook](https://github.com/Kotlin/dataframe/tree/master/examples/notebooks/readme_example.ipynb). + ```kotlin val df = DataFrame // Read DataFrame from the CSV file. @@ -74,15 +131,13 @@ val df = DataFrame // And convert it to match the `Repositories` schema. .convertTo() - // Let's update the DataFrame with some operations using these features. - val reposUpdated = repos +// Update the DataFrame. +val reposUpdated = repos // Rename columns to CamelCase. - // Note that after that, in the following operations, extension properties will have - // new names corresponding to the column names. .renameToCamelCase() // Rename "stargazersCount" column to "stars". .rename { stargazersCount }.into("stars") - // And we can immediately use the updated name in the filtering. + // Filter by the number of stars: .filter { stars > 50 } // Convert values in the "topic" column (which were `String` initially) // to the list of topics. @@ -90,14 +145,11 @@ val df = DataFrame val inner = it.removeSurrounding("[", "]") if (inner.isEmpty()) emptyList() else inner.split(',').map(String::trim) } - // Now "topics" is a `List` column. // Add a new column with the number of topics. .add("topicCount") { topics.size } - // Add a new column with the kind of repository. - .add("kind") { getKind(fullName, topics) } - // Write the updated DataFrame to a CSV file. - reposUpdated.writeCsv("jetbrains_repositories_new.csv") +// Write the updated DataFrame to a CSV file. +reposUpdated.writeCsv("jetbrains_repositories_new.csv") ``` Explore [**more examples here**](https://kotlin.github.io/dataframe/guides-and-examples.html). @@ -109,6 +161,13 @@ Explore [**more examples here**](https://kotlin.github.io/dataframe/guides-and-e * `ColumnGroup` — contains columns * `FrameColumn` — contains dataframes +## Visualisations + +[Kandy](https://kotlin.github.io/kandy/welcome.html) plotting library provides seamless visualizations +for your dataframes. + +![kandy_preview](docs/StardustDocs/images/guides/kandy_gallery_preview.png) + ## Kotlin, Kotlin Jupyter, Arrow, and JDK versions This table shows the mapping between main library component versions and minimum supported Java versions. diff --git a/examples/notebooks/readme_example.ipynb b/examples/notebooks/readme_example.ipynb new file mode 100644 index 000000000..698738290 --- /dev/null +++ b/examples/notebooks/readme_example.ipynb @@ -0,0 +1,2111 @@ +{ + "cells": [ + { + "metadata": {}, + "cell_type": "markdown", + "source": "# Kotlin DataFrame in Kotlin Notebook simple example" + }, + { + "metadata": {}, + "cell_type": "markdown", + "source": [ + "## How to run it?\n", + "\n", + "See [Get started with Kotlin DataFrame in Kotlin Notebook](https://kotlin.github.io/dataframe/gettingstartedkotlinnotebook.html)." + ] + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2025-06-12T14:00:56.038889Z", + "start_time": "2025-06-12T14:00:54.367219Z" + } + }, + "cell_type": "code", + "source": [ + "%useLatestDescriptors\n", + "%use dataframe" + ], + "outputs": [], + "execution_count": 1 + }, + { + "cell_type": "code", + "metadata": { + "collapsed": true, + "ExecuteTime": { + "end_time": "2025-06-12T14:00:57.111986Z", + "start_time": "2025-06-12T14:00:56.042717Z" + } + }, + "source": [ + "val df = DataFrame\n", + " // Read DataFrame from the CSV file.\n", + " .readCsv(\"https://raw.githubusercontent.com/Kotlin/dataframe/master/data/jetbrains_repositories.csv\")\n", + " // Rename column names to CamelCase.\n", + " .renameToCamelCase()\n", + "df" + ], + "outputs": [ + { + "data": { + "text/html": [ + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
fullNamehtmlUrlstargazersCounttopicswatchers
JetBrains/JPShttps://github.com/JetBrains/JPS23[]23
JetBrains/YouTrackSharphttps://github.com/JetBrains/YouTrack...115[jetbrains, jetbrains-youtrack, youtr...115
JetBrains/colorSchemeToolhttps://github.com/JetBrains/colorSch...290[]290
JetBrains/ideavimhttps://github.com/JetBrains/ideavim6120[ideavim, intellij, intellij-platform...6120
JetBrains/youtrack-vcs-hookshttps://github.com/JetBrains/youtrack...5[]5
JetBrains/youtrack-rest-ruby-libraryhttps://github.com/JetBrains/youtrack...8[]8
JetBrains/emacs4ijhttps://github.com/JetBrains/emacs4ij47[]47
JetBrains/codereview4intellijhttps://github.com/JetBrains/coderevi...11[]11
JetBrains/teamcity-nuget-supporthttps://github.com/JetBrains/teamcity...41[nuget, nuget-feed, teamcity, teamcit...41
JetBrains/Grammar-Kithttps://github.com/JetBrains/Grammar-Kit534[]534
JetBrains/intellij-starteam-pluginhttps://github.com/JetBrains/intellij...6[]6
JetBrains/la-clojurehttps://github.com/JetBrains/la-clojure218[]218
JetBrains/MPShttps://github.com/JetBrains/MPS1241[domain-specific-language, dsl]1241
JetBrains/intellij-communityhttps://github.com/JetBrains/intellij...12926[code-editor, ide, intellij, intellij...12926
JetBrains/TeamCity.ServiceMessageshttps://github.com/JetBrains/TeamCity...39[c-sharp, teamcity, teamcity-service-...39
JetBrains/youtrack-rest-python-libraryhttps://github.com/JetBrains/youtrack...118[]118
JetBrains/intellij-scalahttps://github.com/JetBrains/intellij...1066[intellij-idea, intellij-plugin, scala]1066
JetBrains/teamcity-messageshttps://github.com/JetBrains/teamcity...125[]125
JetBrains/teamcity-cpphttps://github.com/JetBrains/teamcity...27[]27
JetBrains/kotlinhttps://github.com/JetBrains/kotlin39402[compiler, gradle-plugin, intellij-pl...39402
\n", + " \n", + " \n", + " " + ], + "application/kotlindataframe+json": "{\"$version\":\"2.1.1\",\"metadata\":{\"columns\":[\"fullName\",\"htmlUrl\",\"stargazersCount\",\"topics\",\"watchers\"],\"types\":[{\"kind\":\"ValueColumn\",\"type\":\"kotlin.String\"},{\"kind\":\"ValueColumn\",\"type\":\"java.net.URL\"},{\"kind\":\"ValueColumn\",\"type\":\"kotlin.Int\"},{\"kind\":\"ValueColumn\",\"type\":\"kotlin.String\"},{\"kind\":\"ValueColumn\",\"type\":\"kotlin.Int\"}],\"nrow\":562,\"ncol\":5},\"kotlin_dataframe\":[{\"fullName\":\"JetBrains/JPS\",\"htmlUrl\":\"https://github.com/JetBrains/JPS\",\"stargazersCount\":23,\"topics\":\"[]\",\"watchers\":23},{\"fullName\":\"JetBrains/YouTrackSharp\",\"htmlUrl\":\"https://github.com/JetBrains/YouTrackSharp\",\"stargazersCount\":115,\"topics\":\"[jetbrains, jetbrains-youtrack, youtrack, youtrack-api]\",\"watchers\":115},{\"fullName\":\"JetBrains/colorSchemeTool\",\"htmlUrl\":\"https://github.com/JetBrains/colorSchemeTool\",\"stargazersCount\":290,\"topics\":\"[]\",\"watchers\":290},{\"fullName\":\"JetBrains/ideavim\",\"htmlUrl\":\"https://github.com/JetBrains/ideavim\",\"stargazersCount\":6120,\"topics\":\"[ideavim, intellij, intellij-platform, jb-official, kotlin, vim, vim-emulator]\",\"watchers\":6120},{\"fullName\":\"JetBrains/youtrack-vcs-hooks\",\"htmlUrl\":\"https://github.com/JetBrains/youtrack-vcs-hooks\",\"stargazersCount\":5,\"topics\":\"[]\",\"watchers\":5},{\"fullName\":\"JetBrains/youtrack-rest-ruby-library\",\"htmlUrl\":\"https://github.com/JetBrains/youtrack-rest-ruby-library\",\"stargazersCount\":8,\"topics\":\"[]\",\"watchers\":8},{\"fullName\":\"JetBrains/emacs4ij\",\"htmlUrl\":\"https://github.com/JetBrains/emacs4ij\",\"stargazersCount\":47,\"topics\":\"[]\",\"watchers\":47},{\"fullName\":\"JetBrains/codereview4intellij\",\"htmlUrl\":\"https://github.com/JetBrains/codereview4intellij\",\"stargazersCount\":11,\"topics\":\"[]\",\"watchers\":11},{\"fullName\":\"JetBrains/teamcity-nuget-support\",\"htmlUrl\":\"https://github.com/JetBrains/teamcity-nuget-support\",\"stargazersCount\":41,\"topics\":\"[nuget, nuget-feed, teamcity, teamcity-plugin]\",\"watchers\":41},{\"fullName\":\"JetBrains/Grammar-Kit\",\"htmlUrl\":\"https://github.com/JetBrains/Grammar-Kit\",\"stargazersCount\":534,\"topics\":\"[]\",\"watchers\":534},{\"fullName\":\"JetBrains/intellij-starteam-plugin\",\"htmlUrl\":\"https://github.com/JetBrains/intellij-starteam-plugin\",\"stargazersCount\":6,\"topics\":\"[]\",\"watchers\":6},{\"fullName\":\"JetBrains/la-clojure\",\"htmlUrl\":\"https://github.com/JetBrains/la-clojure\",\"stargazersCount\":218,\"topics\":\"[]\",\"watchers\":218},{\"fullName\":\"JetBrains/MPS\",\"htmlUrl\":\"https://github.com/JetBrains/MPS\",\"stargazersCount\":1241,\"topics\":\"[domain-specific-language, dsl]\",\"watchers\":1241},{\"fullName\":\"JetBrains/intellij-community\",\"htmlUrl\":\"https://github.com/JetBrains/intellij-community\",\"stargazersCount\":12926,\"topics\":\"[code-editor, ide, intellij, intellij-community, intellij-platform]\",\"watchers\":12926},{\"fullName\":\"JetBrains/TeamCity.ServiceMessages\",\"htmlUrl\":\"https://github.com/JetBrains/TeamCity.ServiceMessages\",\"stargazersCount\":39,\"topics\":\"[c-sharp, teamcity, teamcity-service-messages]\",\"watchers\":39},{\"fullName\":\"JetBrains/youtrack-rest-python-library\",\"htmlUrl\":\"https://github.com/JetBrains/youtrack-rest-python-library\",\"stargazersCount\":118,\"topics\":\"[]\",\"watchers\":118},{\"fullName\":\"JetBrains/intellij-scala\",\"htmlUrl\":\"https://github.com/JetBrains/intellij-scala\",\"stargazersCount\":1066,\"topics\":\"[intellij-idea, intellij-plugin, scala]\",\"watchers\":1066},{\"fullName\":\"JetBrains/teamcity-messages\",\"htmlUrl\":\"https://github.com/JetBrains/teamcity-messages\",\"stargazersCount\":125,\"topics\":\"[]\",\"watchers\":125},{\"fullName\":\"JetBrains/teamcity-cpp\",\"htmlUrl\":\"https://github.com/JetBrains/teamcity-cpp\",\"stargazersCount\":27,\"topics\":\"[]\",\"watchers\":27},{\"fullName\":\"JetBrains/kotlin\",\"htmlUrl\":\"https://github.com/JetBrains/kotlin\",\"stargazersCount\":39402,\"topics\":\"[compiler, gradle-plugin, intellij-plugin, kotlin, kotlin-library, maven-plugin, programming-language]\",\"watchers\":39402}]}" + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 2 + }, + { + "metadata": {}, + "cell_type": "markdown", + "source": [ + "After you run the cell above, [extension properties](https://kotlin.github.io/dataframe/extensionpropertiesapi.html) corresponding to the dataframe columns\n", + "are generated and can be used for column accessing in the dataframe operations:" + ] + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2025-06-12T14:00:57.595522Z", + "start_time": "2025-06-12T14:00:57.199848Z" + } + }, + "cell_type": "code", + "source": [ + "val dfWithUpdatedColumns = df\n", + " // Rename \"stargazersCount\" column to \"stars\".\n", + " .rename { stargazersCount }.into(\"stars\")\n", + " // Convert values in the \"topic\" column (which were `String` initially)\n", + " // to the list of topics.\n", + " .convert { topics }.with {\n", + " val inner = it.removeSurrounding(\"[\", \"]\")\n", + " if (inner.isEmpty()) emptyList() else inner.split(',').map(String::trim)\n", + " }\n", + "dfWithUpdatedColumns" + ], + "outputs": [ + { + "data": { + "text/html": [ + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
fullNamehtmlUrlstarstopicswatchers
JetBrains/JPShttps://github.com/JetBrains/JPS23[ ]23
JetBrains/YouTrackSharphttps://github.com/JetBrains/YouTrack...115[jetbrains, jetbrains-youtrack, youtr...115
JetBrains/colorSchemeToolhttps://github.com/JetBrains/colorSch...290[ ]290
JetBrains/ideavimhttps://github.com/JetBrains/ideavim6120[ideavim, intellij, intellij-platform...6120
JetBrains/youtrack-vcs-hookshttps://github.com/JetBrains/youtrack...5[ ]5
JetBrains/youtrack-rest-ruby-libraryhttps://github.com/JetBrains/youtrack...8[ ]8
JetBrains/emacs4ijhttps://github.com/JetBrains/emacs4ij47[ ]47
JetBrains/codereview4intellijhttps://github.com/JetBrains/coderevi...11[ ]11
JetBrains/teamcity-nuget-supporthttps://github.com/JetBrains/teamcity...41[nuget, nuget-feed, teamcity, teamcit...41
JetBrains/Grammar-Kithttps://github.com/JetBrains/Grammar-Kit534[ ]534
JetBrains/intellij-starteam-pluginhttps://github.com/JetBrains/intellij...6[ ]6
JetBrains/la-clojurehttps://github.com/JetBrains/la-clojure218[ ]218
JetBrains/MPShttps://github.com/JetBrains/MPS1241[domain-specific-language, dsl]1241
JetBrains/intellij-communityhttps://github.com/JetBrains/intellij...12926[code-editor, ide, intellij, intellij...12926
JetBrains/TeamCity.ServiceMessageshttps://github.com/JetBrains/TeamCity...39[c-sharp, teamcity, teamcity-service-...39
JetBrains/youtrack-rest-python-libraryhttps://github.com/JetBrains/youtrack...118[ ]118
JetBrains/intellij-scalahttps://github.com/JetBrains/intellij...1066[intellij-idea, intellij-plugin, scala]1066
JetBrains/teamcity-messageshttps://github.com/JetBrains/teamcity...125[ ]125
JetBrains/teamcity-cpphttps://github.com/JetBrains/teamcity...27[ ]27
JetBrains/kotlinhttps://github.com/JetBrains/kotlin39402[compiler, gradle-plugin, intellij-pl...39402
\n", + " \n", + " \n", + " " + ], + "application/kotlindataframe+json": "{\"$version\":\"2.1.1\",\"metadata\":{\"columns\":[\"fullName\",\"htmlUrl\",\"stars\",\"topics\",\"watchers\"],\"types\":[{\"kind\":\"ValueColumn\",\"type\":\"kotlin.String\"},{\"kind\":\"ValueColumn\",\"type\":\"java.net.URL\"},{\"kind\":\"ValueColumn\",\"type\":\"kotlin.Int\"},{\"kind\":\"ValueColumn\",\"type\":\"kotlin.collections.List\"},{\"kind\":\"ValueColumn\",\"type\":\"kotlin.Int\"}],\"nrow\":562,\"ncol\":5},\"kotlin_dataframe\":[{\"fullName\":\"JetBrains/JPS\",\"htmlUrl\":\"https://github.com/JetBrains/JPS\",\"stars\":23,\"topics\":[],\"watchers\":23},{\"fullName\":\"JetBrains/YouTrackSharp\",\"htmlUrl\":\"https://github.com/JetBrains/YouTrackSharp\",\"stars\":115,\"topics\":[\"jetbrains\",\"jetbrains-youtrack\",\"youtrack\",\"youtrack-api\"],\"watchers\":115},{\"fullName\":\"JetBrains/colorSchemeTool\",\"htmlUrl\":\"https://github.com/JetBrains/colorSchemeTool\",\"stars\":290,\"topics\":[],\"watchers\":290},{\"fullName\":\"JetBrains/ideavim\",\"htmlUrl\":\"https://github.com/JetBrains/ideavim\",\"stars\":6120,\"topics\":[\"ideavim\",\"intellij\",\"intellij-platform\",\"jb-official\",\"kotlin\",\"vim\",\"vim-emulator\"],\"watchers\":6120},{\"fullName\":\"JetBrains/youtrack-vcs-hooks\",\"htmlUrl\":\"https://github.com/JetBrains/youtrack-vcs-hooks\",\"stars\":5,\"topics\":[],\"watchers\":5},{\"fullName\":\"JetBrains/youtrack-rest-ruby-library\",\"htmlUrl\":\"https://github.com/JetBrains/youtrack-rest-ruby-library\",\"stars\":8,\"topics\":[],\"watchers\":8},{\"fullName\":\"JetBrains/emacs4ij\",\"htmlUrl\":\"https://github.com/JetBrains/emacs4ij\",\"stars\":47,\"topics\":[],\"watchers\":47},{\"fullName\":\"JetBrains/codereview4intellij\",\"htmlUrl\":\"https://github.com/JetBrains/codereview4intellij\",\"stars\":11,\"topics\":[],\"watchers\":11},{\"fullName\":\"JetBrains/teamcity-nuget-support\",\"htmlUrl\":\"https://github.com/JetBrains/teamcity-nuget-support\",\"stars\":41,\"topics\":[\"nuget\",\"nuget-feed\",\"teamcity\",\"teamcity-plugin\"],\"watchers\":41},{\"fullName\":\"JetBrains/Grammar-Kit\",\"htmlUrl\":\"https://github.com/JetBrains/Grammar-Kit\",\"stars\":534,\"topics\":[],\"watchers\":534},{\"fullName\":\"JetBrains/intellij-starteam-plugin\",\"htmlUrl\":\"https://github.com/JetBrains/intellij-starteam-plugin\",\"stars\":6,\"topics\":[],\"watchers\":6},{\"fullName\":\"JetBrains/la-clojure\",\"htmlUrl\":\"https://github.com/JetBrains/la-clojure\",\"stars\":218,\"topics\":[],\"watchers\":218},{\"fullName\":\"JetBrains/MPS\",\"htmlUrl\":\"https://github.com/JetBrains/MPS\",\"stars\":1241,\"topics\":[\"domain-specific-language\",\"dsl\"],\"watchers\":1241},{\"fullName\":\"JetBrains/intellij-community\",\"htmlUrl\":\"https://github.com/JetBrains/intellij-community\",\"stars\":12926,\"topics\":[\"code-editor\",\"ide\",\"intellij\",\"intellij-community\",\"intellij-platform\"],\"watchers\":12926},{\"fullName\":\"JetBrains/TeamCity.ServiceMessages\",\"htmlUrl\":\"https://github.com/JetBrains/TeamCity.ServiceMessages\",\"stars\":39,\"topics\":[\"c-sharp\",\"teamcity\",\"teamcity-service-messages\"],\"watchers\":39},{\"fullName\":\"JetBrains/youtrack-rest-python-library\",\"htmlUrl\":\"https://github.com/JetBrains/youtrack-rest-python-library\",\"stars\":118,\"topics\":[],\"watchers\":118},{\"fullName\":\"JetBrains/intellij-scala\",\"htmlUrl\":\"https://github.com/JetBrains/intellij-scala\",\"stars\":1066,\"topics\":[\"intellij-idea\",\"intellij-plugin\",\"scala\"],\"watchers\":1066},{\"fullName\":\"JetBrains/teamcity-messages\",\"htmlUrl\":\"https://github.com/JetBrains/teamcity-messages\",\"stars\":125,\"topics\":[],\"watchers\":125},{\"fullName\":\"JetBrains/teamcity-cpp\",\"htmlUrl\":\"https://github.com/JetBrains/teamcity-cpp\",\"stars\":27,\"topics\":[],\"watchers\":27},{\"fullName\":\"JetBrains/kotlin\",\"htmlUrl\":\"https://github.com/JetBrains/kotlin\",\"stars\":39402,\"topics\":[\"compiler\",\"gradle-plugin\",\"intellij-plugin\",\"kotlin\",\"kotlin-library\",\"maven-plugin\",\"programming-language\"],\"watchers\":39402}]}" + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 3 + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2025-06-12T14:00:57.811581Z", + "start_time": "2025-06-12T14:00:57.672290Z" + } + }, + "cell_type": "code", + "source": [ + "val dfNew = dfWithUpdatedColumns\n", + " // Filter by the number of stars:\n", + " .filter { stars > 50 }\n", + " // Add a new column with the number of topics.\n", + " .add(\"topicCount\") { topics.size }\n", + "dfNew" + ], + "outputs": [ + { + "data": { + "text/html": [ + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
fullNamehtmlUrlstarstopicswatcherstopicCount
JetBrains/YouTrackSharphttps://github.com/JetBrains/YouTrack...115[jetbrains, jetbrains-youtrack, youtr...1154
JetBrains/colorSchemeToolhttps://github.com/JetBrains/colorSch...290[ ]2900
JetBrains/ideavimhttps://github.com/JetBrains/ideavim6120[ideavim, intellij, intellij-platform...61207
JetBrains/Grammar-Kithttps://github.com/JetBrains/Grammar-Kit534[ ]5340
JetBrains/la-clojurehttps://github.com/JetBrains/la-clojure218[ ]2180
JetBrains/MPShttps://github.com/JetBrains/MPS1241[domain-specific-language, dsl]12412
JetBrains/intellij-communityhttps://github.com/JetBrains/intellij...12926[code-editor, ide, intellij, intellij...129265
JetBrains/youtrack-rest-python-libraryhttps://github.com/JetBrains/youtrack...118[ ]1180
JetBrains/intellij-scalahttps://github.com/JetBrains/intellij...1066[intellij-idea, intellij-plugin, scala]10663
JetBrains/teamcity-messageshttps://github.com/JetBrains/teamcity...125[ ]1250
JetBrains/kotlinhttps://github.com/JetBrains/kotlin39402[compiler, gradle-plugin, intellij-pl...394027
JetBrains/kotlin-web-demohttps://github.com/JetBrains/kotlin-w...167[ ]1670
JetBrains/intellij-plugin-verifierhttps://github.com/JetBrains/intellij...113[ ]1130
JetBrains/intellij-sampleshttps://github.com/JetBrains/intellij...146[ ]1460
JetBrains/youtrack-workflowshttps://github.com/JetBrains/youtrack...164[ ]1640
JetBrains/intellij-pluginshttps://github.com/JetBrains/intellij...1737[ ]17370
JetBrains/resharper-nugethttps://github.com/JetBrains/resharpe...94[jetbrains, nuget, resharper, resharp...945
JetBrains/mnemonicshttps://github.com/JetBrains/mnemonics66[jetbrains, mnemonic, resharper, resh...665
JetBrains/karahttps://github.com/JetBrains/kara76[ ]760
JetBrains/jeditermhttps://github.com/JetBrains/jediterm483[ ]4830
\n", + " \n", + " \n", + " " + ], + "application/kotlindataframe+json": "{\"$version\":\"2.1.1\",\"metadata\":{\"columns\":[\"fullName\",\"htmlUrl\",\"stars\",\"topics\",\"watchers\",\"topicCount\"],\"types\":[{\"kind\":\"ValueColumn\",\"type\":\"kotlin.String\"},{\"kind\":\"ValueColumn\",\"type\":\"java.net.URL\"},{\"kind\":\"ValueColumn\",\"type\":\"kotlin.Int\"},{\"kind\":\"ValueColumn\",\"type\":\"kotlin.collections.List\"},{\"kind\":\"ValueColumn\",\"type\":\"kotlin.Int\"},{\"kind\":\"ValueColumn\",\"type\":\"kotlin.Int\"}],\"nrow\":137,\"ncol\":6},\"kotlin_dataframe\":[{\"fullName\":\"JetBrains/YouTrackSharp\",\"htmlUrl\":\"https://github.com/JetBrains/YouTrackSharp\",\"stars\":115,\"topics\":[\"jetbrains\",\"jetbrains-youtrack\",\"youtrack\",\"youtrack-api\"],\"watchers\":115,\"topicCount\":4},{\"fullName\":\"JetBrains/colorSchemeTool\",\"htmlUrl\":\"https://github.com/JetBrains/colorSchemeTool\",\"stars\":290,\"topics\":[],\"watchers\":290,\"topicCount\":0},{\"fullName\":\"JetBrains/ideavim\",\"htmlUrl\":\"https://github.com/JetBrains/ideavim\",\"stars\":6120,\"topics\":[\"ideavim\",\"intellij\",\"intellij-platform\",\"jb-official\",\"kotlin\",\"vim\",\"vim-emulator\"],\"watchers\":6120,\"topicCount\":7},{\"fullName\":\"JetBrains/Grammar-Kit\",\"htmlUrl\":\"https://github.com/JetBrains/Grammar-Kit\",\"stars\":534,\"topics\":[],\"watchers\":534,\"topicCount\":0},{\"fullName\":\"JetBrains/la-clojure\",\"htmlUrl\":\"https://github.com/JetBrains/la-clojure\",\"stars\":218,\"topics\":[],\"watchers\":218,\"topicCount\":0},{\"fullName\":\"JetBrains/MPS\",\"htmlUrl\":\"https://github.com/JetBrains/MPS\",\"stars\":1241,\"topics\":[\"domain-specific-language\",\"dsl\"],\"watchers\":1241,\"topicCount\":2},{\"fullName\":\"JetBrains/intellij-community\",\"htmlUrl\":\"https://github.com/JetBrains/intellij-community\",\"stars\":12926,\"topics\":[\"code-editor\",\"ide\",\"intellij\",\"intellij-community\",\"intellij-platform\"],\"watchers\":12926,\"topicCount\":5},{\"fullName\":\"JetBrains/youtrack-rest-python-library\",\"htmlUrl\":\"https://github.com/JetBrains/youtrack-rest-python-library\",\"stars\":118,\"topics\":[],\"watchers\":118,\"topicCount\":0},{\"fullName\":\"JetBrains/intellij-scala\",\"htmlUrl\":\"https://github.com/JetBrains/intellij-scala\",\"stars\":1066,\"topics\":[\"intellij-idea\",\"intellij-plugin\",\"scala\"],\"watchers\":1066,\"topicCount\":3},{\"fullName\":\"JetBrains/teamcity-messages\",\"htmlUrl\":\"https://github.com/JetBrains/teamcity-messages\",\"stars\":125,\"topics\":[],\"watchers\":125,\"topicCount\":0},{\"fullName\":\"JetBrains/kotlin\",\"htmlUrl\":\"https://github.com/JetBrains/kotlin\",\"stars\":39402,\"topics\":[\"compiler\",\"gradle-plugin\",\"intellij-plugin\",\"kotlin\",\"kotlin-library\",\"maven-plugin\",\"programming-language\"],\"watchers\":39402,\"topicCount\":7},{\"fullName\":\"JetBrains/kotlin-web-demo\",\"htmlUrl\":\"https://github.com/JetBrains/kotlin-web-demo\",\"stars\":167,\"topics\":[],\"watchers\":167,\"topicCount\":0},{\"fullName\":\"JetBrains/intellij-plugin-verifier\",\"htmlUrl\":\"https://github.com/JetBrains/intellij-plugin-verifier\",\"stars\":113,\"topics\":[],\"watchers\":113,\"topicCount\":0},{\"fullName\":\"JetBrains/intellij-samples\",\"htmlUrl\":\"https://github.com/JetBrains/intellij-samples\",\"stars\":146,\"topics\":[],\"watchers\":146,\"topicCount\":0},{\"fullName\":\"JetBrains/youtrack-workflows\",\"htmlUrl\":\"https://github.com/JetBrains/youtrack-workflows\",\"stars\":164,\"topics\":[],\"watchers\":164,\"topicCount\":0},{\"fullName\":\"JetBrains/intellij-plugins\",\"htmlUrl\":\"https://github.com/JetBrains/intellij-plugins\",\"stars\":1737,\"topics\":[],\"watchers\":1737,\"topicCount\":0},{\"fullName\":\"JetBrains/resharper-nuget\",\"htmlUrl\":\"https://github.com/JetBrains/resharper-nuget\",\"stars\":94,\"topics\":[\"jetbrains\",\"nuget\",\"resharper\",\"resharper-extension\",\"resharper-plugin\"],\"watchers\":94,\"topicCount\":5},{\"fullName\":\"JetBrains/mnemonics\",\"htmlUrl\":\"https://github.com/JetBrains/mnemonics\",\"stars\":66,\"topics\":[\"jetbrains\",\"mnemonic\",\"resharper\",\"resharper-extension\",\"resharper-plugin\"],\"watchers\":66,\"topicCount\":5},{\"fullName\":\"JetBrains/kara\",\"htmlUrl\":\"https://github.com/JetBrains/kara\",\"stars\":76,\"topics\":[],\"watchers\":76,\"topicCount\":0},{\"fullName\":\"JetBrains/jediterm\",\"htmlUrl\":\"https://github.com/JetBrains/jediterm\",\"stars\":483,\"topics\":[],\"watchers\":483,\"topicCount\":0}]}" + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "execution_count": 4 + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2025-06-12T14:00:57.886809Z", + "start_time": "2025-06-12T14:00:57.858027Z" + } + }, + "cell_type": "code", + "source": [ + "// Write the updated DataFrame to a CSV file.\n", + "dfNew.writeCsv(\"jetbrains_repositories_new.csv\")" + ], + "outputs": [], + "execution_count": 5 + } + ], + "metadata": { + "kernelspec": { + "display_name": "Kotlin", + "language": "kotlin", + "name": "kotlin" + }, + "language_info": { + "name": "kotlin", + "version": "1.9.23", + "mimetype": "text/x-kotlin", + "file_extension": ".kt", + "pygments_lexer": "kotlin", + "codemirror_mode": "text/x-kotlin", + "nbconvert_exporter": "" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} From 33ff8a5210df52f6e299a5be42b8ed37e50b2bda Mon Sep 17 00:00:00 2001 From: "andrei.kislitsyn" Date: Fri, 13 Jun 2025 16:57:02 +0400 Subject: [PATCH 3/3] readme updates and fixes --- README.md | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 6a739e8f1..f2549a291 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,8 @@ Kotlin DataFrame aims to reconcile Kotlin's static typing with the dynamic natur * **Typesafe** — on-the-fly generation of extension properties for type safe data access with Kotlin-style care for null safety. * **Polymorphic** — type compatibility derives from column schema compatibility. You can define a function that requires a special subset of columns in a dataframe but doesn't care about other columns. -Integrates with [Kotlin kernel for Jupyter](https://github.com/Kotlin/kotlin-jupyter). Inspired by [krangl](https://github.com/holgerbrandl/krangl), Kotlin Collections and [pandas](https://pandas.pydata.org/) +Integrates with [Kotlin Notebook](https://kotlinlang.org/docs/kotlin-notebook-overview.html). +Inspired by [krangl](https://github.com/holgerbrandl/krangl), Kotlin Collections and [pandas](https://pandas.pydata.org/) ## 🚀 Quickstart @@ -30,7 +31,7 @@ Get started in minutes with our [Quickstart Guide](https://kotlin.github.io/data 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](docs/StardustDocs/images/guides/quickstart_preview.png) +[![quickstart_preview](docs/StardustDocs/images/guides/quickstart_preview.png)](https://kotlin.github.io/dataframe/quickstart.html) ## Documentation @@ -62,10 +63,10 @@ Check out this [notebook with new features](examples/notebooks/feature_overviews ### Kotlin Notebook -You can use Kotlin DataFrame in [Kotlin Notebook](https://plugins.jetbrains.com/plugin/16340-kotlin-notebook), -or other interactive environment with Kotlin Jupyter Kernel support, such as -[Datalore](https://datalore.jetbrains.com/), -and [Kotlin Jupyter](https://github.com/Kotlin/kotlin-jupyter). +You can use Kotlin DataFrame in [Kotlin Notebook](https://kotlinlang.org/docs/kotlin-notebook-overview.html), +or other interactive environment with [Kotlin Jupyter Kernel](https://github.com/Kotlin/kotlin-jupyter) support, +such as [Datalore](https://datalore.jetbrains.com/), +and [Jupyter Notebook](https://jupyter.org/). You can include all the necessary dependencies and imports in the notebook using *line magic*: @@ -126,27 +127,27 @@ See also ```kotlin 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() + // 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() // 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 } + // 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") @@ -161,7 +162,7 @@ Explore [**more examples here**](https://kotlin.github.io/dataframe/guides-and-e * `ColumnGroup` — contains columns * `FrameColumn` — contains dataframes -## Visualisations +## Visualizations [Kandy](https://kotlin.github.io/kandy/welcome.html) plotting library provides seamless visualizations for your dataframes.