@@ -90,10 +90,8 @@ def test_groupby_resample_on_api():
90
90
}
91
91
)
92
92
93
- msg = "The default value of numeric_only"
94
- with tm .assert_produces_warning (FutureWarning , match = msg ):
95
- expected = df .set_index ("dates" ).groupby ("key" ).resample ("D" ).mean ()
96
- result = df .groupby ("key" ).resample ("D" , on = "dates" ).mean ()
93
+ expected = df .set_index ("dates" ).groupby ("key" ).resample ("D" ).mean ()
94
+ result = df .groupby ("key" ).resample ("D" , on = "dates" ).mean ()
97
95
tm .assert_frame_equal (result , expected )
98
96
99
97
@@ -187,19 +185,19 @@ def test_api_compat_before_use(attr):
187
185
getattr (rs , attr )
188
186
189
187
190
- def tests_skip_nuisance (test_frame ):
188
+ def tests_raises_on_nuisance (test_frame ):
191
189
192
190
df = test_frame
193
191
df ["D" ] = "foo"
194
192
r = df .resample ("H" )
195
- result = r [["A" , "B" ]].sum ()
196
- expected = pd .concat ([r .A .sum (), r .B .sum ()], axis = 1 )
193
+ result = r [["A" , "B" ]].mean ()
194
+ expected = pd .concat ([r .A .mean (), r .B .mean ()], axis = 1 )
197
195
tm .assert_frame_equal (result , expected )
198
196
199
- expected = r [["A" , "B" , "C" ]].sum ()
200
- msg = "The default value of numeric_only"
201
- with tm . assert_produces_warning ( FutureWarning , match = msg ):
202
- result = r .sum ( )
197
+ expected = r [["A" , "B" , "C" ]].mean ()
198
+ with pytest . raises ( TypeError , match = "Could not convert" ):
199
+ r . mean ()
200
+ result = r .mean ( numeric_only = True )
203
201
tm .assert_frame_equal (result , expected )
204
202
205
203
@@ -681,9 +679,9 @@ def test_selection_api_validation():
681
679
tm .assert_frame_equal (exp , result )
682
680
683
681
exp .index .name = "d"
684
- msg = "The default value of numeric_only"
685
- with tm . assert_produces_warning ( FutureWarning , match = msg ):
686
- result = df .resample ("2D" , level = "d" ).sum ()
682
+ with pytest . raises ( TypeError , match = "datetime64 type does not support sum" ):
683
+ df . resample ( "2D" , level = "d" ). sum ()
684
+ result = df .resample ("2D" , level = "d" ).sum (numeric_only = True )
687
685
tm .assert_frame_equal (exp , result )
688
686
689
687
@@ -819,7 +817,7 @@ def test_end_and_end_day_origin(
819
817
[
820
818
("sum" , True , {"num" : [25 ]}),
821
819
("sum" , False , {"cat" : ["cat_1cat_2" ], "num" : [25 ]}),
822
- ("sum" , lib .no_default , {"num" : [25 ]}),
820
+ ("sum" , lib .no_default , {"cat" : [ "cat_1cat_2" ], " num" : [25 ]}),
823
821
("prod" , True , {"num" : [100 ]}),
824
822
("prod" , False , "can't multiply sequence" ),
825
823
("prod" , lib .no_default , "can't multiply sequence" ),
@@ -837,19 +835,19 @@ def test_end_and_end_day_origin(
837
835
("last" , lib .no_default , {"cat" : ["cat_2" ], "num" : [20 ]}),
838
836
("mean" , True , {"num" : [12.5 ]}),
839
837
("mean" , False , "Could not convert" ),
840
- ("mean" , lib .no_default , { "num" : [ 12.5 ]} ),
838
+ ("mean" , lib .no_default , "Could not convert" ),
841
839
("median" , True , {"num" : [12.5 ]}),
842
840
("median" , False , "could not convert" ),
843
- ("median" , lib .no_default , { "num" : [ 12.5 ]} ),
841
+ ("median" , lib .no_default , "could not convert" ),
844
842
("std" , True , {"num" : [10.606601717798213 ]}),
845
843
("std" , False , "could not convert string to float" ),
846
- ("std" , lib .no_default , { "num" : [ 10.606601717798213 ]} ),
844
+ ("std" , lib .no_default , "could not convert string to float" ),
847
845
("var" , True , {"num" : [112.5 ]}),
848
846
("var" , False , "could not convert string to float" ),
849
- ("var" , lib .no_default , { "num" : [ 112.5 ]} ),
847
+ ("var" , lib .no_default , "could not convert string to float" ),
850
848
("sem" , True , {"num" : [7.5 ]}),
851
849
("sem" , False , "could not convert string to float" ),
852
- ("sem" , lib .no_default , { "num" : [ 7.5 ]} ),
850
+ ("sem" , lib .no_default , "could not convert string to float" ),
853
851
],
854
852
)
855
853
def test_frame_downsample_method (method , numeric_only , expected_data ):
@@ -865,31 +863,14 @@ def test_frame_downsample_method(method, numeric_only, expected_data):
865
863
kwargs = {"numeric_only" : numeric_only }
866
864
867
865
func = getattr (resampled , method )
868
- if numeric_only is lib .no_default and method not in (
869
- "min" ,
870
- "max" ,
871
- "first" ,
872
- "last" ,
873
- "prod" ,
874
- ):
875
- warn = FutureWarning
876
- msg = (
877
- f"default value of numeric_only in DataFrameGroupBy.{ method } is deprecated"
878
- )
866
+ if isinstance (expected_data , str ):
867
+ klass = TypeError if method in ("var" , "mean" , "median" , "prod" ) else ValueError
868
+ with pytest .raises (klass , match = expected_data ):
869
+ _ = func (** kwargs )
879
870
else :
880
- warn = None
881
- msg = ""
882
- with tm .assert_produces_warning (warn , match = msg ):
883
- if isinstance (expected_data , str ):
884
- klass = (
885
- TypeError if method in ("var" , "mean" , "median" , "prod" ) else ValueError
886
- )
887
- with pytest .raises (klass , match = expected_data ):
888
- _ = func (** kwargs )
889
- else :
890
- result = func (** kwargs )
891
- expected = DataFrame (expected_data , index = expected_index )
892
- tm .assert_frame_equal (result , expected )
871
+ result = func (** kwargs )
872
+ expected = DataFrame (expected_data , index = expected_index )
873
+ tm .assert_frame_equal (result , expected )
893
874
894
875
895
876
@pytest .mark .parametrize (
0 commit comments