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:
Also, you can create String Column Accessors that can be used inside the Columns Selection DSL and row expressions using special methods:
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:
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.
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.

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 |