@@ -1686,6 +1686,48 @@ def test_minmax_extensionarray(method, numeric_only):
1686
1686
tm .assert_series_equal (result , expected )
1687
1687
1688
1688
1689
+ def test_mad_nullable_integer (any_signed_int_ea_dtype ):
1690
+ # GH#33036
1691
+ df = DataFrame (np .random .randn (100 , 4 ).astype (np .int64 ))
1692
+ df2 = df .astype (any_signed_int_ea_dtype )
1693
+
1694
+ result = df2 .mad ()
1695
+ expected = df .mad ()
1696
+ tm .assert_series_equal (result , expected )
1697
+
1698
+ result = df2 .mad (axis = 1 )
1699
+ expected = df .mad (axis = 1 )
1700
+ tm .assert_series_equal (result , expected )
1701
+
1702
+ # case with NAs present
1703
+ df2 .iloc [::2 , 1 ] = pd .NA
1704
+
1705
+ result = df2 .mad ()
1706
+ expected = df .mad ()
1707
+ expected [1 ] = df .iloc [1 ::2 , 1 ].mad ()
1708
+ tm .assert_series_equal (result , expected )
1709
+
1710
+ result = df2 .mad (axis = 1 )
1711
+ expected = df .mad (axis = 1 )
1712
+ expected [::2 ] = df .T .loc [[0 , 2 , 3 ], ::2 ].mad ()
1713
+ tm .assert_series_equal (result , expected )
1714
+
1715
+
1716
+ @pytest .mark .xfail (reason = "GH#42895 caused by lack of 2D EA" )
1717
+ def test_mad_nullable_integer_all_na (any_signed_int_ea_dtype ):
1718
+ # GH#33036
1719
+ df = DataFrame (np .random .randn (100 , 4 ).astype (np .int64 ))
1720
+ df2 = df .astype (any_signed_int_ea_dtype )
1721
+
1722
+ # case with all-NA row/column
1723
+ df2 .iloc [:, 1 ] = pd .NA # FIXME: this doesn't operate in-place
1724
+ df2 .iloc [:, 1 ] = pd .array ([pd .NA ] * len (df2 ), dtype = any_signed_int_ea_dtype )
1725
+ result = df2 .mad ()
1726
+ expected = df .mad ()
1727
+ expected [1 ] = pd .NA
1728
+ tm .assert_series_equal (result , expected )
1729
+
1730
+
1689
1731
@pytest .mark .parametrize ("meth" , ["max" , "min" , "sum" , "mean" , "median" ])
1690
1732
def test_groupby_regular_arithmetic_equivalent (meth ):
1691
1733
# GH#40660
0 commit comments