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

Rename mapping to _mapping in .rename() #279

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#### Functionality improvements

* `pl.Null` is rexported as `tp.Null`
* `.rename()` `mapping` renamed to `_mapping` to avoid naming conflicts in
dplyr interface using kwargs

## v0.3.1

Expand Down
10 changes: 5 additions & 5 deletions tidypolars/tibble_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,13 +671,13 @@ def relocate(self, *args, _before = None, _after = None):

return self.select(final_order)

def rename(self, mapping = None, **kwargs):
def rename(self, _mapping = None, **kwargs):
"""
Rename columns

Parameters
----------
mapping : dict
_mapping : dict
Dictionary mapping of new names
**kwargs : str
key-value pair of new name from old name
Expand All @@ -688,9 +688,9 @@ def rename(self, mapping = None, **kwargs):
>>> df.rename(new_x = 'x') # dplyr interface
>>> df.rename({'x': 'new_x'}) # pandas interface
"""
if type(mapping).__name__ == "NoneType":
mapping = {value:key for key, value in kwargs.items()}
return super().rename(mapping).pipe(from_polars)
if _mapping == None:
_mapping = {value:key for key, value in kwargs.items()}
return super().rename(_mapping).pipe(from_polars)

def replace_null(self, replace = None):
"""
Expand Down
Loading