Skip to content

Commit d0a04f8

Browse files
committed
Fixes pandas-dev#24893: re-added lines
1 parent 8460d14 commit d0a04f8

File tree

1 file changed

+5
-25
lines changed

1 file changed

+5
-25
lines changed

pandas/tests/reshape/test_pivot.py

+5-25
Original file line numberDiff line numberDiff line change
@@ -1601,53 +1601,33 @@ 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-
1604+
@pytest.mark.xfail(reason="GH#17035 (np.mean of ints is casted back to ints)")
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, 2, 1.5], [5, 6, 5.5], [3, 4, 3.5]])
1611+
expected = pd.DataFrame([[1.0, 2.0, 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-
1619-
def test_margins_casted_to_float(self, observed):
1620-
# GH #24893
1621-
df = pd.DataFrame(
1622-
{
1623-
"A": [2, 4, 6, 8],
1624-
"B": [1, 4, 5, 8],
1625-
"C": [1, 3, 4, 6],
1626-
"D": ["X", "X", "Y", "Y"],
1627-
}
1628-
)
1629-
1630-
result = pd.pivot_table(df, index="D", margins=True)
1631-
expected = pd.DataFrame(
1632-
{"A": [3, 7, 5], "B": [2.5, 6.5, 4.5], "C": [2, 5, 3.5]},
1633-
index=pd.Index(["X", "Y", "All"], name="D"),
1634-
)
1635-
table = result
1636-
tm.assert_frame_equal(result, expected)
1637-
1618+
@pytest.mark.xfail(reason="GH#17035 (np.mean of ints is casted back to ints)")
16381619
def test_categorical_margins_category(self, observed):
16391620
df = pd.DataFrame(
16401621
{"x": np.arange(8), "y": np.arange(8) // 4, "z": np.arange(8) % 2}
16411622
)
16421623

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

16471628
df.y = df.y.astype("category")
16481629
df.z = df.z.astype("category")
16491630
table = df.pivot_table("x", "y", "z", dropna=observed, margins=True)
1650-
16511631
tm.assert_frame_equal(table, expected)
16521632

16531633
def test_categorical_aggfunc(self, observed):
@@ -2547,4 +2527,4 @@ def test_margin_normalize(self):
25472527
codes=[[1, 1, 2, 2, 0], [1, 2, 1, 2, 0]],
25482528
names=["A", "B"],
25492529
)
2550-
tm.assert_frame_equal(result, expected)
2530+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)