Skip to content

Commit 50e7d64

Browse files
authored
BUG: GH25871 -- fix PEP 8 issues on test source
1 parent b265349 commit 50e7d64

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

pandas/tests/groupby/test_categorical.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -453,28 +453,32 @@ def test_dataframe_categorical_with_nan(observed):
453453
tm.assert_frame_equal(result, expected)
454454

455455

456-
@pytest.mark.parametrize("ordered", [True, False])
456+
@pytest.mark.parametrize("ordered", [True, False])
457457
@pytest.mark.parametrize("observed", [True, False])
458-
@pytest.mark.parametrize("sort", [True, False])
458+
@pytest.mark.parametrize("sort", [True, False])
459459
def test_dataframe_categorical_ordered_observed_sort(ordered, observed, sort):
460-
# GH 25871: Fix groupby sorting on ordered Categoricals
461-
# Build a dataframe with a Categorical having one unobserved category ('AWOL'), and a Series with identical values
462-
cat = pd.Categorical(['d', 'a', 'b', 'a', 'd', 'b'], categories=['a', 'b', 'AWOL', 'd'], ordered=ordered)
463-
val = pd.Series (['d', 'a', 'b', 'a', 'd', 'b'])
464-
df = pd.DataFrame({'cat': cat, 'val': val})
460+
# GH 25871: Fix groupby sorting on ordered Categoricals
461+
# Build a dataframe with a Categorical having one unobserved category ('AWOL'),
462+
# and a Series with identical values
463+
cat = pd.Categorical(['d', 'a', 'b', 'a', 'd', 'b'],
464+
categories=['a', 'b', 'AWOL', 'd'],
465+
ordered=ordered)
466+
val = pd.Series(['d', 'a', 'b', 'a', 'd', 'b'])
467+
df = pd.DataFrame({'cat': cat, 'val': val})
465468

466469
# aggregate on the Categorical
467-
result = df.groupby('cat', observed=observed, sort=sort)['val'].agg('first')
470+
result = (df.groupby('cat', observed=observed, sort=sort)['val']
471+
.aggregate('first'))
468472

469-
# If ordering is correct, we expect index labels equal to aggregation results,
470-
# except for 'observed=False', when index contains 'AWOL' and aggregation None
473+
# If ordering works, we expect index labels equal to aggregation results,
474+
# except for 'observed=False': index contains 'AWOL' and aggregation None
471475
label = pd.Series(result.index.array, dtype='object')
472-
aggr = pd.Series(result.array)
476+
aggr = pd.Series(result.array)
473477
if not observed:
474478
aggr[aggr.isna()] = 'AWOL'
475-
tm.assert_equal(label, aggr)
479+
tm.assert_equal(label, aggr)
480+
476481

477-
478482
def test_datetime():
479483
# GH9049: ensure backward compatibility
480484
levels = pd.date_range('2014-01-01', periods=4)

0 commit comments

Comments
 (0)