Skip to content

Commit ce9ad65

Browse files
authored
CLN: tests.groupby.test_any_all (#53998)
1 parent 03fd49c commit ce9ad65

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

pandas/tests/groupby/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ def dropna(request):
2424
return request.param
2525

2626

27+
@pytest.fixture(params=[True, False])
28+
def skipna(request):
29+
return request.param
30+
31+
2732
@pytest.fixture(params=[True, False])
2833
def observed(request):
2934
return request.param

pandas/tests/groupby/test_any_all.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515

1616
@pytest.mark.parametrize("agg_func", ["any", "all"])
17-
@pytest.mark.parametrize("skipna", [True, False])
1817
@pytest.mark.parametrize(
1918
"vals",
2019
[
@@ -33,7 +32,7 @@
3332
[np.nan, np.nan, np.nan],
3433
],
3534
)
36-
def test_groupby_bool_aggs(agg_func, skipna, vals):
35+
def test_groupby_bool_aggs(skipna, agg_func, vals):
3736
df = DataFrame({"key": ["a"] * 3 + ["b"] * 3, "val": vals * 2})
3837

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

46-
exp_df = DataFrame([exp] * 2, columns=["val"], index=Index(["a", "b"], name="key"))
45+
expected = DataFrame(
46+
[exp] * 2, columns=["val"], index=Index(["a", "b"], name="key")
47+
)
4748
result = getattr(df.groupby("key"), agg_func)(skipna=skipna)
48-
tm.assert_frame_equal(result, exp_df)
49+
tm.assert_frame_equal(result, expected)
4950

5051

5152
def test_any():
@@ -63,7 +64,7 @@ def test_any():
6364

6465
@pytest.mark.parametrize("bool_agg_func", ["any", "all"])
6566
def test_bool_aggs_dup_column_labels(bool_agg_func):
66-
# 21668
67+
# GH#21668
6768
df = DataFrame([[True, True]], columns=["a", "a"])
6869
grp_by = df.groupby([0])
6970
result = getattr(grp_by, bool_agg_func)()
@@ -73,7 +74,6 @@ def test_bool_aggs_dup_column_labels(bool_agg_func):
7374

7475

7576
@pytest.mark.parametrize("bool_agg_func", ["any", "all"])
76-
@pytest.mark.parametrize("skipna", [True, False])
7777
@pytest.mark.parametrize(
7878
"data",
7979
[
@@ -141,7 +141,6 @@ def test_masked_mixed_types(dtype1, dtype2, exp_col1, exp_col2):
141141

142142
@pytest.mark.parametrize("bool_agg_func", ["any", "all"])
143143
@pytest.mark.parametrize("dtype", ["Int64", "Float64", "boolean"])
144-
@pytest.mark.parametrize("skipna", [True, False])
145144
def test_masked_bool_aggs_skipna(bool_agg_func, dtype, skipna, frame_or_series):
146145
# GH#40585
147146
obj = frame_or_series([pd.NA, 1], dtype=dtype)

0 commit comments

Comments
 (0)