insert
Inserts new column at specific position in DataFrame
.
insert
(columnName) { rowExpression } | (column)
.under { parentColumn } | .after { column } | .at(position)
rowExpression: DataRow.(DataRow) -> Value
Similar to add, but supports column positioning.
Create new column based on existing columns and insert it into DataFrame
:
df.insert("year of birth") { 2021 - age }.after { age }
val year = column<Int>("year of birth")
val age by column<Int>()
df.insert(year) { 2021 - age }.after { age }
df.insert("year of birth") { 2021 - "age"<Int>() }.after("age")
Insert previously created column:
val score by columnOf(4, 5, 3, 5, 4, 5, 3)
df.insert(score).at(2)
Last modified: 27 September 2024