Skip to content

Commit

Permalink
Rename mapping to _mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
markfairbanks committed Oct 26, 2024
1 parent 60d0af0 commit e253414
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
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

0 comments on commit e253414

Please sign in to comment.