Skip to content

Commit

Permalink
fix: fix error in Series.drop(0) (#575)
Browse files Browse the repository at this point in the history
Due to implicit 0 non-truthfulness, 0 was getting erroneously converted to None.
  • Loading branch information
milkshakeiii authored and Genesis929 committed Apr 9, 2024
1 parent 149a4fa commit 9917e58
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 5 additions & 3 deletions bigframes/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
raise ValueError("Must specify exacly one of 'labels' or 'index'")
index = labels or index
if (labels is None) == (index is None):
raise ValueError("Must specify exactly one of 'labels' or 'index'")

if labels is not None:
index = labels

# ignore axis, columns params
block = self._block
Expand Down
14 changes: 10 additions & 4 deletions tests/system/small/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9917e58

Please sign in to comment.