Skip to content

Commit 0f18294

Browse files
committed
Revert "Merge branch 'tswast-circular-import' into b366248570-dropna-subset"
This reverts commit 57e8335, reversing changes made to 197074a.
1 parent 6f8f128 commit 0f18294

File tree

5 files changed

+12
-58
lines changed

5 files changed

+12
-58
lines changed

bigframes/core/block_transforms.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import functools
1717
import typing
18-
from typing import Optional, Sequence
18+
from typing import Sequence
1919

2020
import bigframes_vendored.constants as constants
2121
import pandas as pd
@@ -489,19 +489,11 @@ def dropna(
489489
block: blocks.Block,
490490
column_ids: typing.Sequence[str],
491491
how: typing.Literal["all", "any"] = "any",
492-
subset: Optional[typing.Sequence[str]] = None,
493492
):
494493
"""
495494
Drop na entries from block
496495
"""
497-
if subset is None:
498-
subset = column_ids
499-
500-
predicates = [
501-
ops.notnull_op.as_expr(column_id)
502-
for column_id in column_ids
503-
if column_id in subset
504-
]
496+
predicates = [ops.notnull_op.as_expr(column_id) for column_id in column_ids]
505497
if len(predicates) == 0:
506498
return block
507499
if how == "any":

bigframes/dataframe.py

+2-18
Original file line numberDiff line numberDiff line change
@@ -2020,9 +2020,8 @@ def dropna(
20202020
self,
20212021
*,
20222022
axis: int | str = 0,
2023-
how: str = "any",
2024-
subset: typing.Union[None, blocks.Label, Sequence[blocks.Label]] = None,
20252023
inplace: bool = False,
2024+
how: str = "any",
20262025
ignore_index=False,
20272026
) -> DataFrame:
20282027
if inplace:
@@ -2034,23 +2033,8 @@ def dropna(
20342033

20352034
axis_n = utils.get_axis_number(axis)
20362035

2037-
if subset is not None and axis_n != 0:
2038-
raise NotImplementedError(
2039-
f"subset only supported when axis=0. {constants.FEEDBACK_LINK}"
2040-
)
2041-
20422036
if axis_n == 0:
2043-
# subset needs to be converted into column IDs, not column labels.
2044-
if subset is None:
2045-
subset_ids = None
2046-
elif not utils.is_list_like(subset):
2047-
subset_ids = [self._block.label_to_col_id[subset]]
2048-
else:
2049-
subset_ids = [
2050-
id for label in subset for id in self._block.label_to_col_id[label]
2051-
]
2052-
2053-
result = block_ops.dropna(self._block, self._block.value_columns, how=how, subset=subset_ids) # type: ignore
2037+
result = block_ops.dropna(self._block, self._block.value_columns, how=how) # type: ignore
20542038
if ignore_index:
20552039
result = result.reset_index()
20562040
return DataFrame(result)

tests/system/small/test_dataframe.py

+8-13
Original file line numberDiff line numberDiff line change
@@ -936,24 +936,19 @@ def test_assign_callable_lambda(scalars_dfs):
936936

937937
@skip_legacy_pandas
938938
@pytest.mark.parametrize(
939-
("axis", "how", "ignore_index", "subset"),
939+
("axis", "how", "ignore_index"),
940940
[
941-
(0, "any", False, None),
942-
(0, "any", True, None),
943-
(0, "all", False, ["bool_col", "time_col"]),
944-
(0, "any", False, ["bool_col", "time_col"]),
945-
(0, "all", False, "time_col"),
946-
(1, "any", False, None),
947-
(1, "all", False, None),
941+
(0, "any", False),
942+
(0, "any", True),
943+
(1, "any", False),
944+
(1, "all", False),
948945
],
949946
)
950-
def test_df_dropna(scalars_dfs, axis, how, ignore_index, subset):
947+
def test_df_dropna(scalars_dfs, axis, how, ignore_index):
951948
scalars_df, scalars_pandas_df = scalars_dfs
952-
df = scalars_df.dropna(axis=axis, how=how, ignore_index=ignore_index, subset=subset)
949+
df = scalars_df.dropna(axis=axis, how=how, ignore_index=ignore_index)
953950
bf_result = df.to_pandas()
954-
pd_result = scalars_pandas_df.dropna(
955-
axis=axis, how=how, ignore_index=ignore_index, subset=subset
956-
)
951+
pd_result = scalars_pandas_df.dropna(axis=axis, how=how, ignore_index=ignore_index)
957952

958953
# Pandas uses int64 instead of Int64 (nullable) dtype.
959954
pd_result.index = pd_result.index.astype(pd.Int64Dtype())

tests/unit/test_dataframe.py

-9
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@
2020
from . import resources
2121

2222

23-
def test_dataframe_dropna_axis_1_subset_not_implememented(
24-
monkeypatch: pytest.MonkeyPatch,
25-
):
26-
dataframe = resources.create_dataframe(monkeypatch)
27-
28-
with pytest.raises(NotImplementedError, match="subset"):
29-
dataframe.dropna(axis=1, subset=["col1", "col2"])
30-
31-
3223
def test_dataframe_repr_with_uninitialized_object():
3324
"""Ensures DataFrame.__init__ can be paused in a visual debugger without crashing.
3425

third_party/bigframes_vendored/pandas/core/frame.py

-8
Original file line numberDiff line numberDiff line change
@@ -1614,8 +1614,6 @@ def dropna(
16141614
*,
16151615
axis: int | str = 0,
16161616
how: str = "any",
1617-
subset=None,
1618-
inplace: bool = False,
16191617
ignore_index=False,
16201618
) -> DataFrame:
16211619
"""Remove missing values.
@@ -1686,12 +1684,6 @@ def dropna(
16861684
16871685
* 'any' : If any NA values are present, drop that row or column.
16881686
* 'all' : If all values are NA, drop that row or column.
1689-
subset (column label or sequence of labels, optional):
1690-
Labels along other axis to consider, e.g. if you are dropping
1691-
rows these would be a list of columns to include.
1692-
Only supports axis=0.
1693-
inplace (bool, default ``False``):
1694-
Not supported.
16951687
ignore_index (bool, default ``False``):
16961688
If ``True``, the resulting axis will be labeled 0, 1, …, n - 1.
16971689

0 commit comments

Comments
 (0)