Marian Schubert
09/17/2025, 3:47 PMval df = dataFrameOf("id", "props")(
1, mapOf("a" to 10, "b" to 20),
2, mapOf("a" to 30, "b" to 40),
)
is it possible to convert this to dataframe with columns id, a, b
?Jolan Rensen [JB]
09/17/2025, 6:37 PMdf.add {
"a" from { props["a"] }
"b" from { props["b"] }
}.remove { props }
(if you don't have the compiler plugin or you're outside notebooks, this would look like:
df.add {
"a" from { "props"<Map<String, Int>>()["a"] }
"b" from { "props"<Map<String, Int>>()["b"] }
}.remove("props")
)Jolan Rensen [JB]
09/17/2025, 6:38 PMunfold { props }
, but as of now that works unexpectedly)Jolan Rensen [JB]
09/17/2025, 6:45 PMdf.add {
// or however you fetch all keys :)
val keys = props.values().flatMap { it.keys }.toSet()
for (key in keys) {
key from { props[key] }
}
}.remove { props }
Jolan Rensen [JB]
09/17/2025, 6:52 PMfun Map<String, Any?>.toDataRow() = mapValues { listOf(it.value) }.toDataFrame().single()
df.convert { props }.with { it.toDataRow() }.ungroup { props }
this Map.toDataRow()
function will be in the 1.0 release, but not yet in Beta3Marian Schubert
09/18/2025, 8:21 AM