Files
2026-02-08 11:20:43 -10:00

4.7 KiB
Vendored
Raw Permalink Blame History

Setup Kotlin DataFrame in Kotlin Notebook

Use Kotlin DataFrame directly in Kotlin Notebook — write code, explore results, and refine your analysis step by step in a live environment. Start analyzing data with Kotlin DataFrame in Kotlin Notebook — live code execution, rich tables, and zero configuration required. Follow a step-by-step introduction to Kotlin DataFrame in Kotlin Notebook: setup, first DataFrame, and interactive output — all in one place.

Kotlin Notebook is an interactive environment integrated into IntelliJ IDEA (and can be easily added in Android Studio), designed for fast, iterative, and visual data exploration with Kotlin.

The Kotlin Notebook plugin transforms IntelliJ IDEA into a powerful data science workspace, combining Kotlins strong language features with live code execution, interactive data exploration, and rich visualizations.

Its perfect for working with Kotlin DataFrame — letting you write code, view results instantly, and refine your analysis step by step.

Create a Kotlin notebook

Before version 2025.1, Kotlin Notebook is unavailable in IntelliJ IDEA Community Edition and not bundled in IntelliJ IDEA Ultimate Edition by default.
  • Make sure the Kotlin Notebook plugin is enabled.

  • Open an IntelliJ IDEA project (either new or existing).

  • In the project view, create a new Kotlin Notebook file:
    Press or right-click the project tree, then select Kotlin Notebook.

Create Kotlin Notebook file{width="200"}

For more details, see
Get started with Kotlin Notebook
on the official Kotlin Documentation website.

Integrate Kotlin DataFrame

In the new notebook file, execute the following cell to add the Kotlin DataFrame library:

%use dataframe

This will load all necessary dependencies, add required imports, and enable rich DataFrame rendering in the notebook.

Specify a version

By default, if no version is specified, the version bundled with the notebook kernel is used.
You can explicitly define the version you want:

%use dataframe(1.0.0-Beta4n)

Or use the latest stable version of Kotlin DataFrame (specified in Kotlin Jupyter descriptors):

%useLatestDescriptors
%use dataframe

For version 1.0.0-Beta4, in notebooks use version 1.0.0-Beta4n instead. The regular version does not work with statistical functions. The n version includes a patch that resolves this issue.

When using %use dataframe in the latest kernel version or with the %useLatestDescriptors this version is applied automatically.

If you want to include kandy, list it after dataframe:

%useLatestDescriptors
%use dataframe, kandy
// or
%use dataframe(1.0.0-Beta4n), kandy(0.8.3)

{style="warning"}

Hello World

Lets create your first DataFrame in the notebook — a simple "Hello, World!" style example:

val df = dataFrameOf(
  "name" to listOf("Alice", "Bob"),
  "age" to listOf(25, 30)
)

To display it, run a cell with the DataFrame variable in the last line (or simply a cell containing the variable):

df

You will see the content of this DataFrame rendered as an interactive table directly in the cell output:

df_output {height="168"}

Next Steps

  • Once youve successfully set up Kotlin DataFrame in Kotlin Notebook, you can move on to the which walks you through the basics of working with Kotlin DataFrame inside a notebook.

  • For more advanced use cases, explore our collection of detailed guides and real-world examples, showcasing how Kotlin DataFrame can help with a variety of data tasks.

  • Discover powerful that make exploring and understanding your data easier and more effective.

Memory Errors?

  • If you are experiencing OutOfMemoryErrors and heap space errors, you can adjust Notebook's memory settings independently of IntelliJ IDEA's memory settings.

  • In IntelliJ IDEA, go to Settings... Tools... Kotlin Notebook and increase the Max heap size