Skip to content

Commit f19e1bf

Browse files
committed
Replace ordered=True with ordered fixure
1 parent a682baf commit f19e1bf

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

pandas/tests/reshape/test_pivot.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,27 +1656,35 @@ def test_categorical_margins_category(self, observed):
16561656
table = df.pivot_table("x", "y", "z", dropna=observed, margins=True)
16571657
tm.assert_frame_equal(table, expected)
16581658

1659-
def test_pivot_with_categorical(self, observed):
1659+
def test_pivot_with_categorical(self, observed, ordered_fixture):
16601660
# gh-21370
16611661
idx = [np.nan, "low", "high", "low", np.nan]
16621662
col = [np.nan, "A", "B", np.nan, "A"]
16631663
df = pd.DataFrame(
16641664
{
1665-
"In": pd.Categorical(idx, categories=["low", "high"], ordered=True),
1666-
"Col": pd.Categorical(col, categories=["A", "B"], ordered=True),
1665+
"In": pd.Categorical(
1666+
idx, categories=["low", "high"], ordered=ordered_fixture
1667+
),
1668+
"Col": pd.Categorical(
1669+
col, categories=["A", "B"], ordered=ordered_fixture
1670+
),
16671671
"Val": range(1, 6),
16681672
}
16691673
)
16701674
# case with index/columns/value
16711675
result = df.pivot_table(index="In", columns="Col", values="Val")
16721676

1673-
expected_cols = pd.CategoricalIndex(["A", "B"], ordered=True, name="Col")
1677+
expected_cols = pd.CategoricalIndex(
1678+
["A", "B"], ordered=ordered_fixture, name="Col"
1679+
)
16741680

16751681
expected = pd.DataFrame(
16761682
data=[[2.0, np.nan], [np.nan, 3.0]], columns=expected_cols
16771683
)
16781684
expected.index = Index(
1679-
pd.Categorical(["low", "high"], categories=["low", "high"], ordered=True),
1685+
pd.Categorical(
1686+
["low", "high"], categories=["low", "high"], ordered=ordered_fixture
1687+
),
16801688
name="In",
16811689
)
16821690

0 commit comments

Comments
 (0)