-
Notifications
You must be signed in to change notification settings - Fork 133
refactor: rename to with_column_renamed to rename
#908
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,6 +160,9 @@ def with_column(self, name: str, expr: Expr) -> DataFrame: | |
| """ | ||
| return DataFrame(self.df.with_column(name, expr.expr)) | ||
|
|
||
| @deprecated( | ||
| "with_column_renamed() is deprecated. Use :py:meth:`~DataFrame.rename` instead" | ||
| ) | ||
| def with_column_renamed(self, old_name: str, new_name: str) -> DataFrame: | ||
| r"""Rename one column by applying a new projection. | ||
|
|
||
|
|
@@ -175,7 +178,23 @@ def with_column_renamed(self, old_name: str, new_name: str) -> DataFrame: | |
| Returns: | ||
| DataFrame with the column renamed. | ||
| """ | ||
| return DataFrame(self.df.with_column_renamed(old_name, new_name)) | ||
| return DataFrame(self.df.rename({old_name: new_name})) | ||
|
|
||
| def rename(self, mapping: dict[str, str]) -> DataFrame: | ||
| r"""Rename one or multiple columns by applying a new projection. | ||
|
Comment on lines
+180
to
+181
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would argue With columns renamed is quite verbose ^^ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to hear other people's opinions. Also I don't recommend we stray too far from what the upstream DataFusion uses for naming conventions. |
||
|
|
||
| This is a no-op if the column to be renamed does not exist. | ||
|
|
||
| The method supports case sensitive rename with wrapping column name | ||
| into one the following symbols (" or ' or \`). | ||
|
|
||
| Args: | ||
| mapping (dict[str, str]): mapping of old (key) to new (value) names | ||
ion-elgreco marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Returns: | ||
| DataFrame with one or multiple columns renamed. | ||
| """ | ||
| return DataFrame(self.df.rename(mapping)) | ||
|
|
||
| def aggregate( | ||
| self, group_by: list[Expr] | Expr, aggs: list[Expr] | Expr | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.