# insert

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

Inserts a new column at a specific position in [DataFrame](dataframe.html).

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

```TEXT
insert 
    (columnName) { rowExpression } | (column)
    .under { parentColumn } | .after { column } | .at(position)

rowExpression: DataRow.(DataRow) -> Value
```

Similar to [add](add.html), but supports column positioning.

Create new column based on existing columns and insert it into [DataFrame](dataframe.html):

Related operations: [Insert / replace columns](insertreplace.html)

Properties:

```KOTLIN
df.insert("year of birth") { 2021 - age }.after { age }
```

Strings:

```KOTLIN
df.insert("year of birth") { 2021 - "age"<Int>() }.after("age")
```

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

Insert previously created column:

```KOTLIN
val score by columnOf(4, 5, 3, 5, 4, 5, 3)
df.insert(score).at(2)
```

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

