unfold
Returns DataFrame
in which selected data columns are converted to ColumnGroup
/FrameColumn
according to the values of the properties of the objects.
It's a special case of convert operation.
This operation is useful when:
you use a library API that gives you class instances
you do not want to or cannot annotate classes with
@DataSchema
Library API
class RepositoryInfo(val data: Any)
fun downloadRepositoryInfo(url: String) = RepositoryInfo("fancy response from the API")
Consider you have an existing DataFrame
with some URLs, arguments for an API call.
val interestingRepos = dataFrameOf("name", "url")(
"dataframe", "/dataframe",
"kotlin", "/kotlin",
)
val initialData = interestingRepos
.add("response") { downloadRepositoryInfo("url"<String>()) }
Using unfold you can convert response
to a ColumnGroup
and use rich modify capabilities.
val df = initialData.unfold("response")
df.move { response.data }.toTop()
df.rename { response.data }.into("description")
Last modified: 09 December 2024