Skip to content

Commit 19d978a

Browse files
authored
chore(docs): update mutate docs after the last refactoring (#1303)
1 parent 9e21c31 commit 19d978a

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/datachain/lib/dc/datachain.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,17 +1184,13 @@ def group_by( # noqa: C901, PLR0912
11841184
)
11851185

11861186
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.
11921188
11931189
This method is vectorized and more efficient compared to map(), and it does not
11941190
extract or download any data from the internal database. However, it can only
11951191
utilize predefined built-in functions and their combinations.
11961192
1197-
The supported functions:
1193+
Supported functions:
11981194
Numerical: +, -, *, /, rand(), avg(), count(), func(),
11991195
greatest(), least(), max(), min(), sum()
12001196
String: length(), split(), replace(), regexp_replace()
@@ -1221,13 +1217,20 @@ def mutate(self, **kwargs) -> "Self":
12211217
```
12221218
12231219
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.
12261223
12271224
Example:
12281225
```py
12291226
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`
12311234
)
12321235
```
12331236
"""

0 commit comments

Comments
 (0)