@@ -285,16 +285,11 @@ def test_stat_op_api(self, float_frame, float_string_frame):
285285 assert_stat_op_api ("sem" , float_frame , float_string_frame )
286286 assert_stat_op_api ("median" , float_frame , float_string_frame )
287287
288- try :
289- from scipy .stats import ( # noqa:F401
290- kurtosis ,
291- skew ,
292- )
293-
294- assert_stat_op_api ("skew" , float_frame , float_string_frame )
295- assert_stat_op_api ("kurt" , float_frame , float_string_frame )
296- except ImportError :
297- pass
288+ @pytest .mark .filterwarnings ("ignore:Dropping of nuisance:FutureWarning" )
289+ @td .skip_if_no_scipy
290+ def test_stat_op_api_skew_kurt (self , float_frame , float_string_frame ):
291+ assert_stat_op_api ("skew" , float_frame , float_string_frame )
292+ assert_stat_op_api ("kurt" , float_frame , float_string_frame )
298293
299294 def test_stat_op_calc (self , float_frame_with_na , mixed_float_frame ):
300295 def count (s ):
@@ -315,20 +310,6 @@ def std(x):
315310 def sem (x ):
316311 return np .std (x , ddof = 1 ) / np .sqrt (len (x ))
317312
318- def skewness (x ):
319- from scipy .stats import skew # noqa:F811
320-
321- if len (x ) < 3 :
322- return np .nan
323- return skew (x , bias = False )
324-
325- def kurt (x ):
326- from scipy .stats import kurtosis # noqa:F811
327-
328- if len (x ) < 4 :
329- return np .nan
330- return kurtosis (x , bias = False )
331-
332313 assert_stat_op_calc (
333314 "nunique" ,
334315 nunique ,
@@ -371,16 +352,24 @@ def kurt(x):
371352 check_dates = True ,
372353 )
373354
374- try :
375- from scipy import ( # noqa:F401
376- kurtosis ,
377- skew ,
378- )
355+ @td .skip_if_no_scipy
356+ def test_stat_op_calc_skew_kurtosis (self , float_frame_with_na ):
357+ def skewness (x ):
358+ from scipy .stats import skew
359+
360+ if len (x ) < 3 :
361+ return np .nan
362+ return skew (x , bias = False )
363+
364+ def kurt (x ):
365+ from scipy .stats import kurtosis
366+
367+ if len (x ) < 4 :
368+ return np .nan
369+ return kurtosis (x , bias = False )
379370
380- assert_stat_op_calc ("skew" , skewness , float_frame_with_na )
381- assert_stat_op_calc ("kurt" , kurt , float_frame_with_na )
382- except ImportError :
383- pass
371+ assert_stat_op_calc ("skew" , skewness , float_frame_with_na )
372+ assert_stat_op_calc ("kurt" , kurt , float_frame_with_na )
384373
385374 # TODO: Ensure warning isn't emitted in the first place
386375 # ignore mean of empty slice and all-NaN
0 commit comments