From ee9f23657112cee63b509c5462e268a02b5f9048 Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Mon, 1 Apr 2024 12:31:39 +0100 Subject: [PATCH] just accept dict in rename for now --- narwhals/dataframe.py | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/narwhals/dataframe.py b/narwhals/dataframe.py index f60b9fa60..a70a49b21 100644 --- a/narwhals/dataframe.py +++ b/narwhals/dataframe.py @@ -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 @@ -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)