@@ -29,7 +29,8 @@ def test_bins(self):
29
29
result , bins = cut (data , 3 , retbins = True )
30
30
31
31
intervals = IntervalIndex .from_breaks (bins .round (3 ))
32
- expected = intervals .take ([0 , 0 , 0 , 1 , 2 , 0 ]).astype ('category' )
32
+ intervals = intervals .take ([0 , 0 , 0 , 1 , 2 , 0 ])
33
+ expected = Categorical (intervals , ordered = True )
33
34
tm .assert_categorical_equal (result , expected )
34
35
tm .assert_almost_equal (bins , np .array ([0.1905 , 3.36666667 ,
35
36
6.53333333 , 9.7 ]))
@@ -38,7 +39,8 @@ def test_right(self):
38
39
data = np .array ([.2 , 1.4 , 2.5 , 6.2 , 9.7 , 2.1 , 2.575 ])
39
40
result , bins = cut (data , 4 , right = True , retbins = True )
40
41
intervals = IntervalIndex .from_breaks (bins .round (3 ))
41
- expected = intervals .astype ('category' ).take ([0 , 0 , 0 , 2 , 3 , 0 , 0 ])
42
+ expected = Categorical (intervals , ordered = True )
43
+ expected = expected .take ([0 , 0 , 0 , 2 , 3 , 0 , 0 ])
42
44
tm .assert_categorical_equal (result , expected )
43
45
tm .assert_almost_equal (bins , np .array ([0.1905 , 2.575 , 4.95 ,
44
46
7.325 , 9.7 ]))
@@ -47,7 +49,8 @@ def test_noright(self):
47
49
data = np .array ([.2 , 1.4 , 2.5 , 6.2 , 9.7 , 2.1 , 2.575 ])
48
50
result , bins = cut (data , 4 , right = False , retbins = True )
49
51
intervals = IntervalIndex .from_breaks (bins .round (3 ), closed = 'left' )
50
- expected = intervals .take ([0 , 0 , 0 , 2 , 3 , 0 , 1 ]).astype ('category' )
52
+ intervals = intervals .take ([0 , 0 , 0 , 2 , 3 , 0 , 1 ])
53
+ expected = Categorical (intervals , ordered = True )
51
54
tm .assert_categorical_equal (result , expected )
52
55
tm .assert_almost_equal (bins , np .array ([0.2 , 2.575 , 4.95 ,
53
56
7.325 , 9.7095 ]))
@@ -56,7 +59,8 @@ def test_arraylike(self):
56
59
data = [.2 , 1.4 , 2.5 , 6.2 , 9.7 , 2.1 ]
57
60
result , bins = cut (data , 3 , retbins = True )
58
61
intervals = IntervalIndex .from_breaks (bins .round (3 ))
59
- expected = intervals .take ([0 , 0 , 0 , 1 , 2 , 0 ]).astype ('category' )
62
+ intervals = intervals .take ([0 , 0 , 0 , 1 , 2 , 0 ])
63
+ expected = Categorical (intervals , ordered = True )
60
64
tm .assert_categorical_equal (result , expected )
61
65
tm .assert_almost_equal (bins , np .array ([0.1905 , 3.36666667 ,
62
66
6.53333333 , 9.7 ]))
@@ -249,8 +253,8 @@ def test_qcut_nas(self):
249
253
250
254
def test_qcut_index (self ):
251
255
result = qcut ([0 , 2 ], 2 )
252
- expected = Index ( [Interval (- 0.001 , 1 ), Interval (1 , 2 )]). astype (
253
- 'category' )
256
+ intervals = [Interval (- 0.001 , 1 ), Interval (1 , 2 )]
257
+ expected = Categorical ( intervals , ordered = True )
254
258
tm .assert_categorical_equal (result , expected )
255
259
256
260
def test_round_frac (self ):
0 commit comments