Access APIs

Edit pageLast modified: 05 June 2025

By nature, data frames 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 a data frame is tricky.

In the Kotlin DataFrame library, we provide two different ways to access columns

The String API is the simplest and unsafest of them all. The main advantage of it is that it can be used at any time, including when accessing new columns in chain calls. So we can write something like:

In contrast, generated extension properties form the most convenient and the safest API. Using them, you can always be sure that you work with correct data and types. However, there's a bottleneck at the moment of generation. To get new extension properties, you have to run a cell in a notebook, which could lead to unnecessary variable declarations. Currently, we are working on a compiler plugin that generates these properties on the fly while typing!