DataFrame 1.0 Help

Access APIs

By nature, dataframes are dynamic objects; column labels depend on the input source, and new columns can be added or deleted while wrangling. Kotlin, in contrast, is a statically typed language where all types are defined and verified ahead of execution.

That's why creating a flexible, handy, and, at the same time, safe API to access dataframe columns is tricky.

In the Kotlin DataFrame library, we provide two different ways to access columns — the String API and the Extension Properties API.

String API

In the String API, columns are accessed by a String representing their name. Type-checking is done at runtime, name-checking too.

The most basic String API usage is quite intuitive and looks very similar to any other library working with dataframes:

// Get the "fullName" column df["fullName"] // Rename the "fullName" column into "name" df.rename("fullName").into("name")

Also, you can create String Column Accessors that can be used inside the Columns Selection DSL and row expressions using special methods:

// Select the "firstName" column from the "fullName" column group // and the "age" column df.select { "fullName"["firstName"]<String>() and "age"<Int>() } // Takes only rows where the // ("fullName"/"firstName") column value is equal to "Alice" // and "age" column value is greater or equal to 18 df.filter { "fullName"["firstName"]<String>() == "Alice" && "age"<Int>() >= 18 }

Though the String API is the simplest of the two and doesn't require any additional setup, it lacks name- and type-safety; if column names or cast types are incorrect, a runtime exception will be thrown.

Extension Properties API

The Extension Properties API solves the main problems of the String API - name- and type-safety;

This is achieved by generating extension properties for DataFrame<T> (as well as for other related interfaces such as DataRow and others) based on its data schema, which is represented by the type parameter T.
This requires the Kotlin DataFrame Compiler Plugin, or alternatively, usage within the Kotlin Notebook.

The same operations as in the String API can be performed via extension properties concisely and completely name- and typesafe:

// Get "fullName" column df.fullName // Rename "fullName" column into "name" df.rename { fullName }.into("name") // Select the "firstName" column from the "fullName" column group // and the "age" column df.select { fullName.firstName and age } // Takes only rows where the // ("fullName"/"firstName") column value is equal to "Alice" // and "age" column value is greater or equal to 18 df.filter { fullName.firstName == "Alice" && age >= 18 }

Comparing APIs

To better understand the distinction between the two Access APIs, let's look at a concise example of the DataFrame operations chain, presented using both APIs.

val df = DataFrame.read("titanic.csv")
df.add("lastName") { name.split(",").last() } .dropNulls { age } .filter { survived && home.endsWith("NY") && age in 10..20 }
DataFrame.read("titanic.csv") .add("lastName") { "name"<String>().split(",").last() } .dropNulls("age") .filter { "survived"<Boolean>() && "home"<String>().endsWith("NY") && "age"<Int>() in 10..20 }

The Extension Properties API provides column names and -types at compile-time, while the String API could be used with incorrect column names or types and break in runtime.

Additionally, when using IntelliJ IDEA with Gradle or Maven projects that have the Kotlin DataFrame Compiler Plugin enabled, as well as in Kotlin Notebook, code completion fully supports extension properties.

Code Completion

However, note that after operations where the resulting columns cannot be inferred by the Compiler Plugin (for example, pivot), extension properties cannot be inferred automatically either. In such cases, you can use cast to define a new data schema or switch to the String API.

API

Type-checking

Column names checking

Column existence checking

Code completion support

String API

Runtime

Runtime

Runtime

No

Extension Properties API

Compile-time

Compile-time

Compile-time

Yes

23 February 2026