How could I unfold an int-array column into top-le...
# datascience
h
How could I unfold an int-array column into top-level columns?
Copy code
data class BendScore(val foo:String, val bar: Array<Int>)

val scores = listOf(BendScore("A", arrayOf(1,2,3)), BendScore("A", arrayOf(4,5,6)))

 scores.toDataFrame().print()
n
Can you provide a shape of the desired dataframe?
Creating top level columns from values sounds a lot like split into https://kotlin.github.io/dataframe/split.html#split-horizontally Although example on the page is not representative (created just one column named split1). Here's what it does with your data:
Copy code
scores.toDataFrame()
    .split(BendScore::bar)
    .by { it.asList() }
    .into()
Or like this
Copy code
scores.toDataFrame()
    .split(BendScore::bar)
    .by { it.asList() }
    .into { "score$it" }
h
Perfect, that's precisely what I was looking for. Thanks!
r
@Nikita Klimenko [JB] I feel like
split
and
unfold
functions do basically the same thing, probably it's worth to think how unify the API for them