Skip to content

Commit d133890

Browse files
rhshadrachYi Wei
authored and
Yi Wei
committed
TST/CLN: Prepare moving tests out of groupby/test_allowlist (pandas-dev#52851)
1 parent 45a4c5b commit d133890

File tree

1 file changed

+19
-52
lines changed

1 file changed

+19
-52
lines changed

pandas/tests/groupby/test_allowlist.py

+19-52
Original file line numberDiff line numberDiff line change
@@ -3,72 +3,38 @@
33
Do not add tests here!
44
"""
55

6-
from string import ascii_lowercase
7-
8-
import numpy as np
96
import pytest
107

118
from pandas import (
129
DataFrame,
13-
Series,
1410
date_range,
1511
)
1612
import pandas._testing as tm
1713

18-
AGG_FUNCTIONS = [
19-
"sum",
20-
"prod",
21-
"min",
22-
"max",
23-
"median",
24-
"mean",
25-
"skew",
26-
"std",
27-
"var",
28-
"sem",
29-
]
30-
AGG_FUNCTIONS_WITH_SKIPNA = ["skew"]
31-
32-
33-
@pytest.fixture
34-
def df():
35-
return DataFrame(
36-
{
37-
"A": ["foo", "bar", "foo", "bar", "foo", "bar", "foo", "foo"],
38-
"B": ["one", "one", "two", "three", "two", "two", "one", "three"],
39-
"C": np.random.randn(8),
40-
"D": np.random.randn(8),
41-
}
42-
)
43-
44-
45-
@pytest.fixture
46-
def df_letters():
47-
letters = np.array(list(ascii_lowercase))
48-
N = 10
49-
random_letters = letters.take(np.random.randint(0, 26, N))
50-
df = DataFrame(
51-
{
52-
"floats": N / 10 * Series(np.random.random(N)),
53-
"letters": Series(random_letters),
54-
}
55-
)
56-
return df
57-
5814

59-
@pytest.fixture
60-
def raw_frame():
61-
return DataFrame([0])
62-
63-
64-
@pytest.mark.parametrize("op", AGG_FUNCTIONS)
15+
@pytest.mark.parametrize(
16+
"op",
17+
[
18+
"sum",
19+
"prod",
20+
"min",
21+
"max",
22+
"median",
23+
"mean",
24+
"skew",
25+
"std",
26+
"var",
27+
"sem",
28+
],
29+
)
6530
@pytest.mark.parametrize("axis", [0, 1])
6631
@pytest.mark.parametrize("skipna", [True, False])
6732
@pytest.mark.parametrize("sort", [True, False])
68-
def test_regression_allowlist_methods(raw_frame, op, axis, skipna, sort):
33+
def test_regression_allowlist_methods(op, axis, skipna, sort):
6934
# GH6944
7035
# GH 17537
7136
# explicitly test the allowlist methods
37+
raw_frame = DataFrame([0])
7238
if axis == 0:
7339
frame = raw_frame
7440
msg = "The 'axis' keyword in DataFrame.groupby is deprecated and will be"
@@ -79,7 +45,8 @@ def test_regression_allowlist_methods(raw_frame, op, axis, skipna, sort):
7945
with tm.assert_produces_warning(FutureWarning, match=msg):
8046
grouped = frame.groupby(level=0, axis=axis, sort=sort)
8147

82-
if op in AGG_FUNCTIONS_WITH_SKIPNA:
48+
if op == "skew":
49+
# skew has skipna
8350
result = getattr(grouped, op)(skipna=skipna)
8451
expected = frame.groupby(level=0).apply(
8552
lambda h: getattr(h, op)(axis=axis, skipna=skipna)

0 commit comments

Comments
 (0)