@@ -2060,6 +2060,7 @@ def test_pivot_string_as_func(self):
2060
2060
2061
2061
@pytest .mark .parametrize ("kwargs" , [{"a" : 2 }, {"a" : 2 , "b" : 3 }, {"b" : 3 , "a" : 2 }])
2062
2062
def test_pivot_table_kwargs (self , kwargs ):
2063
+ # GH#57884
2063
2064
def f (x , a , b = 3 ):
2064
2065
return x .sum () * a + b
2065
2066
@@ -2079,17 +2080,11 @@ def g(x):
2079
2080
expected = pivot_table (df , index = "A" , columns = "B" , values = "X" , aggfunc = g )
2080
2081
tm .assert_frame_equal (result , expected )
2081
2082
2082
- expected = DataFrame (
2083
- [[np .nan , 43.0 , 13.0 ], [15.0 , np .nan , 23.0 ]],
2084
- columns = Index (["one" , "three" , "two" ], name = "B" ),
2085
- index = Index (["bad" , "good" ], name = "A" ),
2086
- )
2087
- tm .assert_frame_equal (result , expected )
2088
-
2089
2083
@pytest .mark .parametrize (
2090
2084
"kwargs" , [{}, {"b" : 10 }, {"a" : 3 }, {"a" : 3 , "b" : 10 }, {"b" : 10 , "a" : 3 }]
2091
2085
)
2092
2086
def test_pivot_table_kwargs_margin (self , data , kwargs ):
2087
+ # GH#57884
2093
2088
def f (x , a = 5 , b = 7 ):
2094
2089
return (x .sum () + b ) * a
2095
2090
@@ -2117,22 +2112,6 @@ def g(x):
2117
2112
2118
2113
tm .assert_frame_equal (result , expected )
2119
2114
2120
- grand_margin = g (data ["D" ])
2121
-
2122
- margin_col = pivot_table (
2123
- data , values = "D" , index = ["A" , "B" ], aggfunc = g , fill_value = 0
2124
- )
2125
- margin_col .loc [("All" , "" ), "D" ] = grand_margin
2126
- margin_col = margin_col ["D" ]
2127
- margin_col .name = "All"
2128
- tm .assert_series_equal (result ["All" ], margin_col )
2129
-
2130
- margin_row = pivot_table (data , values = "D" , columns = "C" , aggfunc = g , fill_value = 0 )
2131
- margin_row ["All" ] = grand_margin
2132
- margin_row .index = ["" ]
2133
- margin_row .index .name = "B"
2134
- tm .assert_frame_equal (result .loc ["All" ], margin_row )
2135
-
2136
2115
@pytest .mark .parametrize (
2137
2116
"f, f_numpy" ,
2138
2117
[
0 commit comments