# move

> For the complete documentation index, see [llms.txt](https://kotlin.github.io/dataframe/llms.txt).

Moves one or several columns within [DataFrame](dataframe.html).

API reference: [move](https://kotlin.github.io/dataframe/api-docs/core/org.jetbrains.kotlinx.dataframe.api/move.html)

```KOTLIN
move { columns }
    .into { pathSelector } | .under { parentColumn } | .after { column } | .to(position) | .toTop() | .toStart() | .toEnd()

pathSelector: DataFrame.(DataColumn) -> ColumnPath
```

Related operations: [Move / rename / reorder columns](moverename.html)

See [column selectors](columnselectors.html) for how to select the columns for this operation.

Can be used to change column hierarchy by providing `ColumnPath` for every moved column.

```KOTLIN
df.move { age }.toStart()

df.move { weight }.to(1)

// age -> info.age
// weight -> info.weight
df.move { age and weight }.into { pathOf("info", it.name()) }
df.move { age and weight }.into { "info"[it.name()] }
df.move { age and weight }.under("info")

// name.firstName -> fullName.first
// name.lastName -> fullName.last
df.move { name.firstName and name.lastName }.into { pathOf("fullName", it.name().dropLast(4)) }

// a|b|c -> a.b.c
// a|d|e -> a.d.e
dataFrameOf("a|b|c", "a|d|e")(0, 0)
    .move { all() }.into { it.name().split("|").toPath() }

// name.firstName -> firstName
// name.lastName -> lastName
df.move { name.allCols() }.toTop()

// a.b.e -> be
// c.d.e -> de
df.move { colsAtAnyDepth().nameContains("e") }.toTop { it.parentName + it.name() }
```

[Embedded content](resources/org.jetbrains.kotlinx.dataframe.samples.api.Modify.move.html)

Special cases of `move`:

* [group](group.html) — groups columns into [ColumnGroups](datacolumn.html#columngroup)

* [ungroup](ungroup.html) — ungroups [ColumnGroups](datacolumn.html#columngroup)

* [flatten](flatten.html) — removes all column groupings

