Skip to content

Commit 75dd786

Browse files
authored
fix: fix error in Series.drop(0) (#575)
Due to implicit 0 non-truthfulness, 0 was getting erroneously converted to None.
1 parent 9084df3 commit 75dd786

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

bigframes/series.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,11 @@ def drop(
351351
columns: Union[blocks.Label, typing.Iterable[blocks.Label]] = None,
352352
level: typing.Optional[LevelType] = None,
353353
) -> Series:
354-
if labels and index:
355-
raise ValueError("Must specify exacly one of 'labels' or 'index'")
356-
index = labels or index
354+
if (labels is None) == (index is None):
355+
raise ValueError("Must specify exactly one of 'labels' or 'index'")
356+
357+
if labels is not None:
358+
index = labels
357359

358360
# ignore axis, columns params
359361
block = self._block

tests/system/small/test_series.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -1529,10 +1529,16 @@ def test_groupby_window_ops(scalars_df_index, scalars_pandas_df_index, operator)
15291529
)
15301530

15311531

1532-
def test_drop_label(scalars_df_index, scalars_pandas_df_index):
1533-
col_name = "int64_col"
1534-
bf_series = scalars_df_index[col_name].drop(1).to_pandas()
1535-
pd_series = scalars_pandas_df_index[col_name].drop(1)
1532+
@pytest.mark.parametrize(
1533+
("label", "col_name"),
1534+
[
1535+
(0, "bool_col"),
1536+
(1, "int64_col"),
1537+
],
1538+
)
1539+
def test_drop_label(scalars_df_index, scalars_pandas_df_index, label, col_name):
1540+
bf_series = scalars_df_index[col_name].drop(label).to_pandas()
1541+
pd_series = scalars_pandas_df_index[col_name].drop(label)
15361542
pd.testing.assert_series_equal(
15371543
pd_series,
15381544
bf_series,

0 commit comments

Comments
 (0)