Skip to content

Commit

Permalink
just accept dict in rename for now
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Apr 1, 2024
1 parent 674f5ac commit ee9f236
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions narwhals/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,7 @@ def rename(self, mapping: dict[str, str]) -> Self:
Rename column names.
Arguments:
mapping: Key value pairs that map from old name to new name, or a function
that takes the old name as input and returns the new name.
mapping: Key value pairs that map from old name to new name.
Examples:
>>> import polars as pl
Expand All @@ -462,23 +461,6 @@ def rename(self, mapping: dict[str, str]) -> Self:
│ 2 ┆ 7 ┆ b │
│ 3 ┆ 8 ┆ c │
└───────┴─────┴─────┘
>>> dframe = df.rename(lambda column_name: "f" + column_name[1:])
>>> dframe
┌─────────────────────────────────────────────────┐
| Narwhals DataFrame |
| Use `narwhals.to_native()` to see native output |
└─────────────────────────────────────────────────┘
>>> nw.to_native(dframe)
shape: (3, 3)
┌─────┬─────┬─────┐
│ foo ┆ far ┆ fam │
│ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ str │
╞═════╪═════╪═════╡
│ 1 ┆ 6 ┆ a │
│ 2 ┆ 7 ┆ b │
│ 3 ┆ 8 ┆ c │
└─────┴─────┴─────┘
"""
return super().rename(mapping)

Expand Down

0 comments on commit ee9f236

Please sign in to comment.