3
3
import numpy as np
4
4
import pytest
5
5
6
+ import pandas .util ._test_decorators as td
7
+
6
8
from pandas import DataFrame , Series
7
9
import pandas .util .testing as tm
8
10
@@ -26,8 +28,10 @@ def method(self, request):
26
28
"""
27
29
return request .param
28
30
31
+ @td .skip_if_no_scipy
29
32
def test_rank (self , float_frame ):
30
- rankdata = pytest .importorskip ("scipy.stats.rankdata" )
33
+ import scipy .stats # noqa:F401
34
+ from scipy .stats import rankdata
31
35
32
36
float_frame ["A" ][::2 ] = np .nan
33
37
float_frame ["B" ][::3 ] = np .nan
@@ -117,8 +121,10 @@ def test_rank_mixed_frame(self, float_string_frame):
117
121
expected = float_string_frame .rank (1 , numeric_only = True )
118
122
tm .assert_frame_equal (result , expected )
119
123
124
+ @td .skip_if_no_scipy
120
125
def test_rank_na_option (self , float_frame ):
121
- rankdata = pytest .importorskip ("scipy.stats.rankdata" )
126
+ import scipy .stats # noqa:F401
127
+ from scipy .stats import rankdata
122
128
123
129
float_frame ["A" ][::2 ] = np .nan
124
130
float_frame ["B" ][::3 ] = np .nan
@@ -199,9 +205,10 @@ def test_rank_axis(self):
199
205
tm .assert_frame_equal (df .rank (axis = 0 ), df .rank (axis = "index" ))
200
206
tm .assert_frame_equal (df .rank (axis = 1 ), df .rank (axis = "columns" ))
201
207
208
+ @td .skip_if_no_scipy
202
209
def test_rank_methods_frame (self ):
203
- pytest . importorskip ( " scipy.stats.special" )
204
- rankdata = pytest . importorskip ( " scipy.stats. rankdata" )
210
+ import scipy .stats # noqa:F401
211
+ from scipy .stats import rankdata
205
212
206
213
xs = np .random .randint (0 , 21 , (100 , 26 ))
207
214
xs = (xs - 10.0 ) / 10.0
0 commit comments