Kotlin / Kotlin/dataframe

API idea: name-based-destructuring

Open
#1,819 0 comments 0 reactions 0 assignees View on GitHub
API
Dominant language
Kotlin
Stars
1.1k
Forks
83
Avg merge
4d 12h
Merged PRs (30d)
30

Description

Background:
https://kotlinlang.org/docs/whatsnew2320.html#name-based-destructuring
https://github.com/Kotlin/KEEP/discussions/438
https://github.com/Kotlin/KEEP/blob/main/proposals/KEEP-0438-name-based-destructuring.md
https://youtrack.jetbrains.com/issue/KT-19627

We could think about adding these to the API for DataFrames, columns, and rows.

For instance:

Position based:
```kt
val [value1, value2, value3] = myColumn
[val value1, val value2, val value3] = myColumn

// if added, though, better alternatives already exist
df.select { cols { [firstVal] -> firstVal == 0 } }
```
```kt
val [value1, value2, value3] = myRow
[val value1, val value2, val value3] = myRow

// we already have better alternatives here too
df.filter { [value1, value2] -> value1 == 0 || value2 == 0 }
```
```kt
val [row1, row2, row3] = myDf
[val row1, val row2, val row3] = myDf
```

Name based (more useful!):
```kt
val (colA, colB) = myRow
(val name = colA, val colB) = myRow

// inline and partial renaming of column value names is now possible!
df.filter { (val name = colA, val colB) -> name == "" || colB == 0 }
```
```kt
val (colA, colB) = myDf
(val nameCol = colA, val colB) = myDf
```

It's already possible to experiment with this, though the implementation in Kotlin is not final yet.

Contributor guide

Open the contributing guide

Research direction

Start by reading the Kotlin name-based destructuring documentation and KEEP-0438 proposal linked in the issue, then review the related YouTrack ticket. Compare the idea against existing DataFrame, column, and row APIs. Done would require a settled API design and an agreed implementation scope for name-based destructuring.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.