Skip to content

Commit 578c5e0

Browse files
committed
Fixes pandas-dev#24893: updated tests
1 parent 537354c commit 578c5e0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pandas/tests/reshape/test_pivot.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1601,21 +1601,22 @@ def test_pivot_table_margins_name_with_aggfunc_list(self):
16011601
expected = pd.DataFrame(table.values, index=ix, columns=cols)
16021602
tm.assert_frame_equal(table, expected)
16031603

1604-
@pytest.mark.xfail(reason="GH#17035 (np.mean of ints is casted back to ints)")
1604+
16051605
def test_categorical_margins(self, observed):
16061606
# GH 10989
16071607
df = pd.DataFrame(
16081608
{"x": np.arange(8), "y": np.arange(8) // 4, "z": np.arange(8) % 2}
16091609
)
16101610

1611-
expected = pd.DataFrame([[1.0, 2.0, 1.5], [5, 6, 5.5], [3, 4, 3.5]])
1611+
expected = pd.DataFrame([[1, 2, 1.5], [5, 6, 5.5], [3, 4, 3.5]])
16121612
expected.index = Index([0, 1, "All"], name="y")
16131613
expected.columns = Index([0, 1, "All"], name="z")
16141614

16151615
table = df.pivot_table("x", "y", "z", dropna=observed, margins=True)
16161616
tm.assert_frame_equal(table, expected)
16171617

1618-
def test_margins_casted_to_float(self):
1618+
1619+
def test_margins_casted_to_float(self, observed):
16191620
# GH #24893
16201621
df = pd.DataFrame(
16211622
{
@@ -1631,21 +1632,22 @@ def test_margins_casted_to_float(self):
16311632
{"A": [3, 7, 5], "B": [2.5, 6.5, 4.5], "C": [2, 5, 3.5]},
16321633
index=pd.Index(["X", "Y", "All"], name="D"),
16331634
)
1635+
table = result
16341636
tm.assert_frame_equal(result, expected)
16351637

1636-
@pytest.mark.xfail(reason="GH#17035 (np.mean of ints is casted back to ints)")
16371638
def test_categorical_margins_category(self, observed):
16381639
df = pd.DataFrame(
16391640
{"x": np.arange(8), "y": np.arange(8) // 4, "z": np.arange(8) % 2}
16401641
)
16411642

1642-
expected = pd.DataFrame([[1.0, 2.0, 1.5], [5, 6, 5.5], [3, 4, 3.5]])
1643+
expected = pd.DataFrame([[1, 2, 1.5], [5, 6, 5.5], [3, 4, 3.5]])
16431644
expected.index = Index([0, 1, "All"], name="y")
16441645
expected.columns = Index([0, 1, "All"], name="z")
16451646

16461647
df.y = df.y.astype("category")
16471648
df.z = df.z.astype("category")
16481649
table = df.pivot_table("x", "y", "z", dropna=observed, margins=True)
1650+
16491651
tm.assert_frame_equal(table, expected)
16501652

16511653
def test_categorical_aggfunc(self, observed):

0 commit comments

Comments
 (0)