Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutate can rename columns #312

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/datachain/lib/dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,17 @@ def mutate(self, **kwargs) -> "Self":
dist=cosine_distance(embedding_text, embedding_image)
)
```

This method also has enhanced capabilities for renaming the columns. If column
srini047 marked this conversation as resolved.
Show resolved Hide resolved
with the current name exists then its renamed. Orelse a new column is created
srini047 marked this conversation as resolved.
Show resolved Hide resolved
from the existing one.

Example:
```py
dc.mutate(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need a new string here? seems that it's small enough to fit the same line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I get more clarity on the same.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's minor, not a blocker:

just to clarify - what I meant is to have

dc.mutate(newkey=Column("oldkey"))

(w/o extra newlines).

Again, not a blocker at all, just a suggestion to consider.

oldkey=Column("newkey")
srini047 marked this conversation as resolved.
Show resolved Hide resolved
)
```
"""
for col_name, expr in kwargs.items():
if not isinstance(expr, Column) and isinstance(expr.type, NullType):
Expand Down