# update

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

Returns [DataFrame](dataframe.html) with changed values in some cells. Column types cannot be changed.

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

```TEXT
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
```

Related operations: [Update / convert values](updateconvert.html)

See [column selectors](columnselectors.html) for how to select the columns for this operation and [row expressions](datarow.html#row-expressions) for how to specify the new values.

```KOTLIN
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()
```

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

Update with constant value:

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

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

Update with value depending on row:

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

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

Update with value depending on column:

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

Update with value depending on row and column:

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

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

Update [ColumnGroup](datacolumn.html#columngroup) as [DataFrame](dataframe.html):

```KOTLIN
df.update { name }.asFrame { select { lastName } }
```

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

