Skip to content

Commit

Permalink
Mutate can rename columns (#312)
Browse files Browse the repository at this point in the history
* docs: add mutate rename columns

* docs: update based on pr review

---------

Co-authored-by: Ivan Shcheklein <shcheklein@gmail.com>
  • Loading branch information
srini047 and shcheklein authored Aug 21, 2024
1 parent 2a7e870 commit 20b42d6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/datachain/lib/dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,17 @@ def mutate(self, **kwargs) -> "Self":
dist=cosine_distance(embedding_text, embedding_image)
)
```
This method can be also used to rename signals. If the Column("name") provided
as value for the new signal - the old column will be dropped. Otherwise a new
column is created.
Example:
```py
dc.mutate(
newkey=Column("oldkey")
)
```
"""
existing_columns = set(self.signals_schema.values.keys())
for col_name in kwargs:
Expand Down

0 comments on commit 20b42d6

Please sign in to comment.