@@ -285,16 +285,11 @@ def test_stat_op_api(self, float_frame, float_string_frame):
285
285
assert_stat_op_api ("sem" , float_frame , float_string_frame )
286
286
assert_stat_op_api ("median" , float_frame , float_string_frame )
287
287
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 )
298
293
299
294
def test_stat_op_calc (self , float_frame_with_na , mixed_float_frame ):
300
295
def count (s ):
@@ -315,20 +310,6 @@ def std(x):
315
310
def sem (x ):
316
311
return np .std (x , ddof = 1 ) / np .sqrt (len (x ))
317
312
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
-
332
313
assert_stat_op_calc (
333
314
"nunique" ,
334
315
nunique ,
@@ -371,16 +352,24 @@ def kurt(x):
371
352
check_dates = True ,
372
353
)
373
354
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 )
379
370
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 )
384
373
385
374
# TODO: Ensure warning isn't emitted in the first place
386
375
# ignore mean of empty slice and all-NaN
0 commit comments