diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a14f81..12d1359 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/tidypolars/tibble_df.py b/tidypolars/tibble_df.py index 88e15d9..efc2c11 100644 --- a/tidypolars/tibble_df.py +++ b/tidypolars/tibble_df.py @@ -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 @@ -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): """