Dataframe 0.13 Help

update

Returns DataFrame with changed values in some cells. Column types can not be changed.

update { columns } [.where { rowCondition } ] [.at(rowIndices) ] .with { rowExpression } | .notNull { rowExpression } | .perCol { colExpression } | .perRowCol { rowColExpression } | .withNull() | .withZero() | .asFrame { frameExpression } rowCondition: DataRow.(OldValue) -> Boolean rowExpression: DataRow.(OldValue) -> NewValue colExpression: DataColumn.(DataColumn) -> NewValue rowColExpression: (DataRow, DataColumn) -> NewValue frameExpression: DataFrame.(DataFrame) -> DataFrame

See column selectors and row expressions

df.update { age }.with { it * 2 } df.update { colsAtAnyDepth().colsOf<String>() }.with { it.uppercase() } df.update { weight }.at(1..4).notNull { it / 2 } df.update { name.lastName and age }.at(1, 3, 4).withNull()

Update with constant value:

df.update { city }.where { name.firstName == "Alice" }.with { "Paris" }

Update with value depending on row:

df.update { city }.with { name.firstName + " from " + it }

Update with value depending on column:

df.update { colsOf<Number?>() }.perCol { mean(skipNA = true) }

Update with value depending on row and column:

df.update { colsOf<String?>() }.perRowCol { row, col -> col.name() + ": " + row.index() }

Update ColumnGroup as DataFrame:

df.update { name }.asFrame { select { lastName } }
Last modified: 29 March 2024