Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLN: tests.groupby.test_any_all #53998

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pandas/tests/groupby/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def dropna(request):
return request.param


@pytest.fixture(params=[True, False])
def skipna(request):
return request.param


@pytest.fixture(params=[True, False])
def observed(request):
return request.param
Expand Down
13 changes: 6 additions & 7 deletions pandas/tests/groupby/test_any_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


@pytest.mark.parametrize("agg_func", ["any", "all"])
@pytest.mark.parametrize("skipna", [True, False])
@pytest.mark.parametrize(
"vals",
[
Expand All @@ -33,7 +32,7 @@
[np.nan, np.nan, np.nan],
],
)
def test_groupby_bool_aggs(agg_func, skipna, vals):
def test_groupby_bool_aggs(skipna, agg_func, vals):
df = DataFrame({"key": ["a"] * 3 + ["b"] * 3, "val": vals * 2})

# Figure out expectation using Python builtin
Expand All @@ -43,9 +42,11 @@ def test_groupby_bool_aggs(agg_func, skipna, vals):
if skipna and all(isna(vals)) and agg_func == "any":
exp = False

exp_df = DataFrame([exp] * 2, columns=["val"], index=Index(["a", "b"], name="key"))
expected = DataFrame(
[exp] * 2, columns=["val"], index=Index(["a", "b"], name="key")
)
result = getattr(df.groupby("key"), agg_func)(skipna=skipna)
tm.assert_frame_equal(result, exp_df)
tm.assert_frame_equal(result, expected)


def test_any():
Expand All @@ -63,7 +64,7 @@ def test_any():

@pytest.mark.parametrize("bool_agg_func", ["any", "all"])
def test_bool_aggs_dup_column_labels(bool_agg_func):
# 21668
# GH#21668
df = DataFrame([[True, True]], columns=["a", "a"])
grp_by = df.groupby([0])
result = getattr(grp_by, bool_agg_func)()
Expand All @@ -73,7 +74,6 @@ def test_bool_aggs_dup_column_labels(bool_agg_func):


@pytest.mark.parametrize("bool_agg_func", ["any", "all"])
@pytest.mark.parametrize("skipna", [True, False])
@pytest.mark.parametrize(
"data",
[
Expand Down Expand Up @@ -141,7 +141,6 @@ def test_masked_mixed_types(dtype1, dtype2, exp_col1, exp_col2):

@pytest.mark.parametrize("bool_agg_func", ["any", "all"])
@pytest.mark.parametrize("dtype", ["Int64", "Float64", "boolean"])
@pytest.mark.parametrize("skipna", [True, False])
def test_masked_bool_aggs_skipna(bool_agg_func, dtype, skipna, frame_or_series):
# GH#40585
obj = frame_or_series([pd.NA, 1], dtype=dtype)
Expand Down