reorderColumnsByName
Puts all columns of the DataFrame in lexicographic order of their names and returns a new DataFrame.
It is a shortcut for reorderColumnsBy with { name() }.
With atAnyDepth set to true (the default), the columns inside every column group are reordered too, each within its own group. With atAnyDepth set to false, only the top-level columns are reordered, and the nested columns keep their order.
The columns inside the dataframes of a frame column keep their order: like colsAtAnyDepth, atAnyDepth does not look inside frame columns. To reorder them too, pass inFrameColumns = true.
The values in the columns do not change.
To reorder only some of the columns, use reorder with byName.
For more information: See reorderColumnsByName on the documentation website.
Examples:
// df: [name[firstName, lastName], age, city, weight, isHappy]
// The nested columns of "name" are reordered too
df.reorderColumnsByName(desc = true) // [weight, name[lastName, firstName], isHappy, city, age]
// The nested columns of "name" keep their order
df.reorderColumnsByName(atAnyDepth = false, desc = true) // [weight, name[firstName, lastName], isHappy, city, age]Return
A new DataFrame with all columns reordered.
Parameters
If true, the columns inside column groups are reordered too. true by default.
If true, the columns are put in descending order. false by default.
Puts all columns of the DataFrame in lexicographic order of their names and returns a new DataFrame.
It is a shortcut for reorderColumnsBy with { name() }.
With atAnyDepth set to true (the default), the columns inside every column group are reordered too, each within its own group. With atAnyDepth set to false, only the top-level columns are reordered, and the nested columns keep their order.
With inFrameColumns set to true, the columns inside every DataFrame of a frame column are reordered too, each dataframe on its own and with the same atAnyDepth. With inFrameColumns set to false, they keep their order: like colsAtAnyDepth, atAnyDepth does not look inside frame columns.
The values in the columns do not change.
To reorder only some of the columns, use reorder with byName.
For more information: See reorderColumnsByName on the documentation website.
Examples:
// df: [name[firstName, lastName], age, city, weight, isHappy]
// The nested columns of "name" are reordered too
df.reorderColumnsByName(desc = true) // [weight, name[lastName, firstName], isHappy, city, age]
// The nested columns of "name" keep their order
df.reorderColumnsByName(atAnyDepth = false, desc = true) // [weight, name[firstName, lastName], isHappy, city, age]Return
A new DataFrame with all columns reordered.
Parameters
If true, the columns inside column groups are reordered too. true by default.
If true, the columns are put in descending order. false by default.
If true, the columns inside frame columns are reordered too.