From 715ea6040a32b761b072eaf5e74275a036f8eebf Mon Sep 17 00:00:00 2001 From: raisa <> Date: Thu, 21 Mar 2024 14:46:11 +0000 Subject: [PATCH 1/4] wip --- narwhals/series.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/narwhals/series.py b/narwhals/series.py index fc4c442ed..18b9d44ac 100644 --- a/narwhals/series.py +++ b/narwhals/series.py @@ -107,6 +107,12 @@ def is_null(self) -> Self: def drop_nulls(self) -> Self: return self._from_series(self._series.drop_nulls()) + # def mean(self) -> Any: + # return self._from_series(self._series.mean()) + + # def std(self) -> Any: + # return self._from_series(self._series.std()) + def n_unique(self) -> int: return self._series.n_unique() # type: ignore[no-any-return] From 8e18f1a46a8d2aee189036ec46d593f2aa0775c9 Mon Sep 17 00:00:00 2001 From: raisa <> Date: Thu, 21 Mar 2024 14:49:34 +0000 Subject: [PATCH 2/4] remove mean and std from series as were already defined --- narwhals/series.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/narwhals/series.py b/narwhals/series.py index 18b9d44ac..fc4c442ed 100644 --- a/narwhals/series.py +++ b/narwhals/series.py @@ -107,12 +107,6 @@ def is_null(self) -> Self: def drop_nulls(self) -> Self: return self._from_series(self._series.drop_nulls()) - # def mean(self) -> Any: - # return self._from_series(self._series.mean()) - - # def std(self) -> Any: - # return self._from_series(self._series.std()) - def n_unique(self) -> int: return self._series.n_unique() # type: ignore[no-any-return] From ddc072f7e545e2c29a29007883c5198283426325 Mon Sep 17 00:00:00 2001 From: raisa <> Date: Thu, 28 Mar 2024 14:29:50 +0000 Subject: [PATCH 3/4] modify pandas-like merge to have the same behaviour as in Polars --- narwhals/pandas_like/dataframe.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/narwhals/pandas_like/dataframe.py b/narwhals/pandas_like/dataframe.py index d2106fcf1..48a03ad59 100644 --- a/narwhals/pandas_like/dataframe.py +++ b/narwhals/pandas_like/dataframe.py @@ -177,18 +177,13 @@ def join( if isinstance(right_on, str): right_on = [right_on] - if overlap := (set(self.columns) - set(left_on)).intersection( - set(other.columns) - set(right_on), - ): - msg = f"Found overlapping columns in join: {overlap}. Please rename columns to avoid this." - raise ValueError(msg) - return self._from_dataframe( self._dataframe.merge( other._dataframe, left_on=left_on, right_on=right_on, how=how, + suffixes=("", "_right"), ), ) From fb75c28085b0691e9694fd65f3d904d7e22cbfed Mon Sep 17 00:00:00 2001 From: raisa <> Date: Thu, 28 Mar 2024 14:41:55 +0000 Subject: [PATCH 4/4] modify join test to check for overlapping column names --- tests/test_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_common.py b/tests/test_common.py index 45a51eef3..02d77cb77 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -173,7 +173,7 @@ def test_rename(df_raw: Any) -> None: @pytest.mark.parametrize("df_raw", [df_pandas, df_lazy]) def test_join(df_raw: Any) -> None: df = nw.LazyFrame(df_raw) - df_right = df.rename({"z": "z_right"}) + df_right = df result = df.join(df_right, left_on=["a", "b"], right_on=["a", "b"], how="inner") result_native = nw.to_native(result) expected = {"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8, 9], "z_right": [7.0, 8, 9]}