From 03d2704cc10df6dd70d952e34f4d776ca6088d70 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Thu, 12 Sep 2024 04:33:50 -0400 Subject: [PATCH] fix doc strings for clone on LazyFrame (#952) --- narwhals/dataframe.py | 57 ++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/narwhals/dataframe.py b/narwhals/dataframe.py index 1b91f0910..e66bdacec 100644 --- a/narwhals/dataframe.py +++ b/narwhals/dataframe.py @@ -3851,34 +3851,35 @@ def clone(self) -> Self: r""" Create a copy of this DataFrame. - >>> import narwhals as nw - >>> import pandas as pd - >>> import polars as pl - >>> data = {"a": [1, 2], "b": [3, 4]} - >>> df_pd = pd.DataFrame(data) - >>> df_pl = pl.LazyFrame(data) - - Let's define a dataframe-agnostic function in which we copy the DataFrame: - - >>> @nw.narwhalify - ... def func(df): - ... return df.clone() - - >>> func(df_pd) - a b - 0 1 3 - 1 2 4 - - >>> func(df_pl).collect() - shape: (2, 2) - ┌─────┬─────┐ - │ a ┆ b │ - │ --- ┆ --- │ - │ i64 ┆ i64 │ - ╞═════╪═════╡ - │ 1 ┆ 3 │ - │ 2 ┆ 4 │ - └─────┴─────┘ + Examples: + >>> import narwhals as nw + >>> import pandas as pd + >>> import polars as pl + >>> data = {"a": [1, 2], "b": [3, 4]} + >>> df_pd = pd.DataFrame(data) + >>> df_pl = pl.LazyFrame(data) + + Let's define a dataframe-agnostic function in which we copy the DataFrame: + + >>> @nw.narwhalify + ... def func(df): + ... return df.clone() + + >>> func(df_pd) + a b + 0 1 3 + 1 2 4 + + >>> func(df_pl).collect() + shape: (2, 2) + ┌─────┬─────┐ + │ a ┆ b │ + │ --- ┆ --- │ + │ i64 ┆ i64 │ + ╞═════╪═════╡ + │ 1 ┆ 3 │ + │ 2 ┆ 4 │ + └─────┴─────┘ """ return super().clone()