unfold
Returns a ColumnGroup made from the objects of this column, with a column for every public property of these objects, or this column itself when it cannot be unfolded.
The new columns are named after the properties, in the order of the primary constructor (for a class without one, in the order of their names), and the ColumnGroup has the name of the column it is made from. An object that is null gives null in every new column, except that a list property that becomes a FrameColumn gets an empty DataFrame. The properties are those of the type T of this column as the compiler sees it. When T cannot be unfolded itself, such as Any? of an untyped column, they are those of the type of the column instead.
A column that cannot be unfolded stays as it is. These are columns of simple values, such as numbers, strings, or enums, columns of objects without public properties, columns where both T and the type are Any (for example, with objects of different classes), ColumnGroups, and FrameColumns.
With the default maxDepth = 0, the values of the properties stay as they are: a nested object stays an object, and a list stays a list. With maxDepth = 1, nested objects become ColumnGroups, and lists of objects become FrameColumns; every further step goes one level deeper.
Properties of a DataSchema type, lists of them, DataRows, and DataFrames are always unfolded into ColumnGroups and FrameColumns.
For more information: See unfold on the documentation website.
See also:
toDataFrame— builds aDataFramefrom anIterableof objects by reading their properties.flattenandungroup— remove the column groups thatunfoldcreates.convertandreplace— change the selected columns in any other way.
Don't confuse this with explode, which puts the elements of lists into separate rows.
Example
// `student` is a column of `Student(name: Name, age: Int, scores: List<Score>)` objects;
// `name` becomes a column group too, and `scores` a frame column
df.student.unfold(maxDepth = 1)Return
A ColumnGroup with the name of this column, or this column itself when it cannot be unfolded.
Parameters
How deep to unfold the values of the properties. By default, 0: they stay as they are.
Returns a new DataFrame in which the selected columns of objects are turned into ColumnGroups, with a column for every public property of these objects. The other columns and the order of the columns stay the same.
The new columns are named after the properties, in the order of the primary constructor (for a class without one, in the order of their names), and the ColumnGroup has the name of the column it is made from. An object that is null gives null in every new column, except that a list property that becomes a FrameColumn gets an empty DataFrame. The properties are those of the type of each selected column.
A column that cannot be unfolded stays as it is. These are columns of simple values, such as numbers, strings, or enums, columns of objects without public properties, columns whose type is Any (for example, with objects of different classes), ColumnGroups, and FrameColumns.
With the default maxDepth = 0, the values of the properties stay as they are: a nested object stays an object, and a list stays a list. With maxDepth = 1, nested objects become ColumnGroups, and lists of objects become FrameColumns; every further step goes one level deeper.
Properties of a DataSchema type, lists of them, DataRows, and DataFrames are always unfolded into ColumnGroups and FrameColumns.
With the compiler plugin, a call with roots gets an empty compile-time schema for now, so the result has no typed accessors (#2115).
For more information: See unfold on the documentation website.
See also:
toDataFrame— builds aDataFramefrom anIterableof objects by reading their properties.flattenandungroup— remove the column groups thatunfoldcreates.convertandreplace— change the selected columns in any other way.
Don't confuse this with explode, which puts the elements of lists into separate rows.
See Selecting Columns.
Select or express columns using the Columns Selection DSL.
This DSL is initiated by a Columns Selector lambda, which operates in the context of the Columns Selection DSL and expects you to return a SingleColumn or ColumnSet (so, a ColumnsResolver). This is an entity formed by calling any (combination) of the functions in the DSL that is or can be resolved into one or more columns.
The Columns Selection DSL allows using Extension Properties for specifying columns type- and name-safe.
Check out: Columns Selection DSL Grammar
See Column Selectors on the documentation website.
Examples
// `student` is a column of `Student(name: Name, age: Int, scores: List<Score>)` objects
df.unfold { student }
// `name` becomes a column group too, and `scores` a frame column
df.unfold(maxDepth = 1) { student }
// only the `name` and `age` properties
df.unfold(Student::name, Student::age) { student }Return
A new DataFrame with the selected columns unfolded.
Parameters
How deep to unfold the values of the properties. By default, 0: they stay as they are.
The Columns Selector used to select the columns of this DataFrame to unfold.
Returns a new DataFrame in which the selected columns of objects are turned into ColumnGroups, with a column for every public property of these objects. The other columns and the order of the columns stay the same.
The new columns are named after the properties, in the order of the primary constructor (for a class without one, in the order of their names), and the ColumnGroup has the name of the column it is made from. An object that is null gives null in every new column, except that a list property that becomes a FrameColumn gets an empty DataFrame. The properties are those of the type of each selected column.
A column that cannot be unfolded stays as it is. These are columns of simple values, such as numbers, strings, or enums, columns of objects without public properties, columns whose type is Any (for example, with objects of different classes), ColumnGroups, and FrameColumns.
The values of the properties stay as they are: a nested object stays an object, and a list stays a list.
Properties of a DataSchema type, lists of them, DataRows, and DataFrames are always unfolded into ColumnGroups and FrameColumns. To unfold nested objects as well, or to take only some of the properties, use the overload with a Columns Selector and its maxDepth and roots parameters.
For more information: See unfold on the documentation website.
See also:
toDataFrame— builds aDataFramefrom anIterableof objects by reading their properties.flattenandungroup— remove the column groups thatunfoldcreates.convertandreplace— change the selected columns in any other way.
Don't confuse this with explode, which puts the elements of lists into separate rows.
See Selecting Columns.
Select single or multiple columns using their names as Strings. (String API).
For example:
df.unfold("length", "age")
Example
// `student` is a column of `Student(name: Name, age: Int, scores: List<Score>)` objects
df.unfold("student")Return
A new DataFrame with the selected columns unfolded.
Parameters
The names of the columns of this DataFrame to unfold.
Deprecated
It's recommended to migrate to the String or Extension Properties Access API https://kotlin.github.io/dataframe/apilevels.html