-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kotlin Notebook crash when creating DataFrame from List<Map> #710
Comments
Working solution
|
Need to check - does it have the same behaviour in the Gradle projects |
It works fine in gradle projects, so we'll need to check what weird type inference is going on in the Jupyter integration... It creates a DataFrame like:
However, was this the solution you were looking for? I suspect you want to create a dataframe with a column Constructing a DataFrame is usually done by column and not by row, as that's how they're stored in memory. That's why all DataFrame creation methods are built the way they are. If you have a val df = (1..1000).map {
mapOf("id" to it, "value" to "value$it")
}.toDataFrame {
source.map { it["id"] }.toColumn() into "id"
source.map { it["value"] }.toColumn() into "value"
} If you really have to construct a DataFrame row by row, in theory you could but it would essentially entail making many small DFs and concatenating them, like: val df = (1..1000).map {
mapOf("id" to it, "value" to "value$it")
}.map {
dataFrameOf(header = it.keys, values = it.values)
}.concat() |
Ah yeah. Good explanation. I just copied some code from ChatGPT as part of testing something else when I saw the crash. So I didn't realize that it did things slightly wrong. |
@cmelchior could we close? |
This code:
Crashes Kotlin Notebooks with:
The text was updated successfully, but these errors were encountered: