@@ -87,13 +87,15 @@ def test_max_min_object_multiple_columns(using_array_manager):
8787
8888 gb = df .groupby ("A" )
8989
90- result = gb .max (numeric_only = False )
90+ with tm .assert_produces_warning (FutureWarning , match = "Dropping invalid" ):
91+ result = gb .max (numeric_only = False )
9192 # "max" is valid for column "C" but not for "B"
9293 ei = Index ([1 , 2 , 3 ], name = "A" )
9394 expected = DataFrame ({"C" : ["b" , "d" , "e" ]}, index = ei )
9495 tm .assert_frame_equal (result , expected )
9596
96- result = gb .min (numeric_only = False )
97+ with tm .assert_produces_warning (FutureWarning , match = "Dropping invalid" ):
98+ result = gb .min (numeric_only = False )
9799 # "min" is valid for column "C" but not for "B"
98100 ei = Index ([1 , 2 , 3 ], name = "A" )
99101 expected = DataFrame ({"C" : ["a" , "c" , "e" ]}, index = ei )
@@ -221,7 +223,10 @@ def test_averages(self, df, method):
221223 ],
222224 )
223225
224- result = getattr (gb , method )(numeric_only = False )
226+ with tm .assert_produces_warning (
227+ FutureWarning , match = "Dropping invalid" , check_stacklevel = False
228+ ):
229+ result = getattr (gb , method )(numeric_only = False )
225230 tm .assert_frame_equal (result .reindex_like (expected ), expected )
226231
227232 expected_columns = expected .columns
@@ -303,10 +308,27 @@ def test_cummin_cummax(self, df, method):
303308 def _check (self , df , method , expected_columns , expected_columns_numeric ):
304309 gb = df .groupby ("group" )
305310
306- result = getattr (gb , method )()
311+ # cummin, cummax dont have numeric_only kwarg, always use False
312+ warn = None
313+ if method in ["cummin" , "cummax" ]:
314+ # these dont have numeric_only kwarg, always use False
315+ warn = FutureWarning
316+ elif method in ["min" , "max" ]:
317+ # these have numeric_only kwarg, but default to False
318+ warn = FutureWarning
319+
320+ with tm .assert_produces_warning (warn , match = "Dropping invalid columns" ):
321+ result = getattr (gb , method )()
322+
307323 tm .assert_index_equal (result .columns , expected_columns_numeric )
308324
309- result = getattr (gb , method )(numeric_only = False )
325+ # GH#41475 deprecated silently ignoring nuisance columns
326+ warn = None
327+ if len (expected_columns ) < len (gb ._obj_with_exclusions .columns ):
328+ warn = FutureWarning
329+ with tm .assert_produces_warning (warn , match = "Dropping invalid columns" ):
330+ result = getattr (gb , method )(numeric_only = False )
331+
310332 tm .assert_index_equal (result .columns , expected_columns )
311333
312334
0 commit comments