From 5c3a1b5a3949e4034dbb54bde2350e789d2d3977 Mon Sep 17 00:00:00 2001 From: milkshakeiii Date: Thu, 4 Apr 2024 01:43:45 +0000 Subject: [PATCH 1/4] fix: fix error in --- bigframes/series.py | 6 ++++-- tests/system/small/test_series.py | 14 ++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bigframes/series.py b/bigframes/series.py index e7b358c2fe..c547ae0d6e 100644 --- a/bigframes/series.py +++ b/bigframes/series.py @@ -351,9 +351,11 @@ def drop( columns: Union[blocks.Label, typing.Iterable[blocks.Label]] = None, level: typing.Optional[LevelType] = None, ) -> Series: - if labels and index: + if labels is None and index is None: raise ValueError("Must specify exacly one of 'labels' or 'index'") - index = labels or index + + if labels is not None: + index = labels # ignore axis, columns params block = self._block diff --git a/tests/system/small/test_series.py b/tests/system/small/test_series.py index 794ab6b7a2..65ba6b0c27 100644 --- a/tests/system/small/test_series.py +++ b/tests/system/small/test_series.py @@ -1529,10 +1529,16 @@ def test_groupby_window_ops(scalars_df_index, scalars_pandas_df_index, operator) ) -def test_drop_label(scalars_df_index, scalars_pandas_df_index): - col_name = "int64_col" - bf_series = scalars_df_index[col_name].drop(1).to_pandas() - pd_series = scalars_pandas_df_index[col_name].drop(1) +@pytest.mark.parametrize( + ("label", "col_name"), + [ + (0, "bool_col"), + (1, "int64_col"), + ], +) +def test_drop_label(scalars_df_index, scalars_pandas_df_index, label, col_name): + bf_series = scalars_df_index[col_name].drop(label).to_pandas() + pd_series = scalars_pandas_df_index[col_name].drop(label) pd.testing.assert_series_equal( pd_series, bf_series, From 9f5469b665370c2d912a106f3ade89fd944ac81a Mon Sep 17 00:00:00 2001 From: milkshakeiii Date: Thu, 4 Apr 2024 01:49:51 +0000 Subject: [PATCH 2/4] fix typo --- bigframes/series.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigframes/series.py b/bigframes/series.py index c547ae0d6e..0fffe25212 100644 --- a/bigframes/series.py +++ b/bigframes/series.py @@ -351,7 +351,7 @@ def drop( columns: Union[blocks.Label, typing.Iterable[blocks.Label]] = None, level: typing.Optional[LevelType] = None, ) -> Series: - if labels is None and index is None: + if labels is not None and index is not None: raise ValueError("Must specify exacly one of 'labels' or 'index'") if labels is not None: From af350f1c22451fa93117c373b7c36fd735ea4744 Mon Sep 17 00:00:00 2001 From: milkshakeiii Date: Thu, 4 Apr 2024 02:00:37 +0000 Subject: [PATCH 3/4] improve error in edge case (match pandas) --- bigframes/series.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigframes/series.py b/bigframes/series.py index 0fffe25212..c68503847d 100644 --- a/bigframes/series.py +++ b/bigframes/series.py @@ -351,7 +351,7 @@ def drop( columns: Union[blocks.Label, typing.Iterable[blocks.Label]] = None, level: typing.Optional[LevelType] = None, ) -> Series: - if labels is not None and index is not None: + if (labels is None) == (index is None): raise ValueError("Must specify exacly one of 'labels' or 'index'") if labels is not None: From 3d61afc30716d3e2302522b0400ccdfdb57268cf Mon Sep 17 00:00:00 2001 From: milkshakeiii Date: Thu, 4 Apr 2024 02:01:29 +0000 Subject: [PATCH 4/4] fix spelling --- bigframes/series.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigframes/series.py b/bigframes/series.py index c68503847d..aeb00033a1 100644 --- a/bigframes/series.py +++ b/bigframes/series.py @@ -352,7 +352,7 @@ def drop( level: typing.Optional[LevelType] = None, ) -> Series: if (labels is None) == (index is None): - raise ValueError("Must specify exacly one of 'labels' or 'index'") + raise ValueError("Must specify exactly one of 'labels' or 'index'") if labels is not None: index = labels