@@ -1184,17 +1184,13 @@ def group_by( # noqa: C901, PLR0912
1184
1184
)
1185
1185
1186
1186
def mutate (self , ** kwargs ) -> "Self" :
1187
- """Create new signals based on existing signals.
1188
-
1189
- This method cannot modify existing columns. If you need to modify an
1190
- existing column, use a different name for the new column and then use
1191
- `select()` to choose which columns to keep.
1187
+ """Create or modify signals based on existing signals.
1192
1188
1193
1189
This method is vectorized and more efficient compared to map(), and it does not
1194
1190
extract or download any data from the internal database. However, it can only
1195
1191
utilize predefined built-in functions and their combinations.
1196
1192
1197
- The supported functions:
1193
+ Supported functions:
1198
1194
Numerical: +, -, *, /, rand(), avg(), count(), func(),
1199
1195
greatest(), least(), max(), min(), sum()
1200
1196
String: length(), split(), replace(), regexp_replace()
@@ -1221,13 +1217,20 @@ def mutate(self, **kwargs) -> "Self":
1221
1217
```
1222
1218
1223
1219
This method can be also used to rename signals. If the Column("name") provided
1224
- as value for the new signal - the old column will be dropped. Otherwise a new
1225
- column is created.
1220
+ as value for the new signal - the old signal will be dropped. Otherwise a new
1221
+ signal is created. Exception, if the old signal is nested one (e.g.
1222
+ `C("file.path")`), it will be kept to keep the object intact.
1226
1223
1227
1224
Example:
1228
1225
```py
1229
1226
dc.mutate(
1230
- newkey=Column("oldkey")
1227
+ newkey=Column("oldkey") # drops oldkey
1228
+ )
1229
+ ```
1230
+
1231
+ ```py
1232
+ dc.mutate(
1233
+ size=Column("file.size") # keeps `file.size`
1231
1234
)
1232
1235
```
1233
1236
"""
0 commit comments