Dataframe 0.14 Help

reorder

Returns DataFrame with a new order of selected columns.

reorder { columns } [.cast<ColumnType>() ] .by { columnExpression } | .byDesc { columnExpression } | .byName(desc = false) { columnExpression } columnExpression: DataColumn.(DataColumn) -> Value
df.reorder { age..isHappy }.byName()
val age by column<Int>() val isHappy by column<Boolean>() df.reorder { age..isHappy }.byName()
df.reorder { "age".."isHappy" }.byName() }

When a subset of columns is selected they will be reordered among their original positions. Positions of other columns will not change.

If selected columns belong to different column groups they will be reordered within their groups, so column grouping will be preserved.

val df = dataFrameOf("c", "d", "a", "b")( 3, 4, 1, 2, 1, 1, 1, 1, ) df.reorder("d", "b").cast<Int>().by { sum() } // [c, b, a, d]

When exactly one ColumnGroup is selected, reordering is applied to its nested columns.

df.reorder { name }.byName(desc = true) // [name.lastName, name.firstName]

reorderColumnsBy

Reorders all columns

reorderColumnsBy(dfs = true, desc = false) { columnExpression }

Parameters:

reorderColumnsByName

reorderColumnsByName(dfs = true, desc = false)

Parameters:

Last modified: 27 September 2024