5
5
RangeIndex ,
6
6
)
7
7
import pandas ._testing as tm
8
- from pandas .core .indexes .api import Int64Index
9
8
10
9
11
10
class TestJoin :
12
11
def test_join_outer (self ):
13
- # join with Int64Index
12
+ # join with Index[int64]
14
13
index = RangeIndex (start = 0 , stop = 20 , step = 2 )
15
- other = Int64Index (np .arange (25 , 14 , - 1 ))
14
+ other = Index (np .arange (25 , 14 , - 1 , dtype = np . int64 ))
16
15
17
16
res , lidx , ridx = index .join (other , how = "outer" , return_indexers = True )
18
17
noidx_res = index .join (other , how = "outer" )
19
18
tm .assert_index_equal (res , noidx_res )
20
19
21
- eres = Int64Index (
20
+ eres = Index (
22
21
[0 , 2 , 4 , 6 , 8 , 10 , 12 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 ]
23
22
)
24
23
elidx = np .array (
@@ -30,9 +29,9 @@ def test_join_outer(self):
30
29
dtype = np .intp ,
31
30
)
32
31
33
- assert isinstance (res , Int64Index )
32
+ assert isinstance (res , Index ) and res . dtype == np . int64
34
33
assert not isinstance (res , RangeIndex )
35
- tm .assert_index_equal (res , eres )
34
+ tm .assert_index_equal (res , eres , exact = True )
36
35
tm .assert_numpy_array_equal (lidx , elidx )
37
36
tm .assert_numpy_array_equal (ridx , eridx )
38
37
@@ -43,7 +42,7 @@ def test_join_outer(self):
43
42
noidx_res = index .join (other , how = "outer" )
44
43
tm .assert_index_equal (res , noidx_res )
45
44
46
- assert isinstance (res , Int64Index )
45
+ assert isinstance (res , Index ) and res . dtype == np . int64
47
46
assert not isinstance (res , RangeIndex )
48
47
tm .assert_index_equal (res , eres )
49
48
tm .assert_numpy_array_equal (lidx , elidx )
@@ -52,7 +51,7 @@ def test_join_outer(self):
52
51
def test_join_inner (self ):
53
52
# Join with non-RangeIndex
54
53
index = RangeIndex (start = 0 , stop = 20 , step = 2 )
55
- other = Int64Index (np .arange (25 , 14 , - 1 ))
54
+ other = Index (np .arange (25 , 14 , - 1 , dtype = np . int64 ))
56
55
57
56
res , lidx , ridx = index .join (other , how = "inner" , return_indexers = True )
58
57
@@ -62,7 +61,7 @@ def test_join_inner(self):
62
61
lidx = lidx .take (ind )
63
62
ridx = ridx .take (ind )
64
63
65
- eres = Int64Index ([16 , 18 ])
64
+ eres = Index ([16 , 18 ])
66
65
elidx = np .array ([8 , 9 ], dtype = np .intp )
67
66
eridx = np .array ([9 , 7 ], dtype = np .intp )
68
67
@@ -82,9 +81,9 @@ def test_join_inner(self):
82
81
tm .assert_numpy_array_equal (ridx , eridx )
83
82
84
83
def test_join_left (self ):
85
- # Join with Int64Index
84
+ # Join with Index[int64]
86
85
index = RangeIndex (start = 0 , stop = 20 , step = 2 )
87
- other = Int64Index (np .arange (25 , 14 , - 1 ))
86
+ other = Index (np .arange (25 , 14 , - 1 , dtype = np . int64 ))
88
87
89
88
res , lidx , ridx = index .join (other , how = "left" , return_indexers = True )
90
89
eres = index
@@ -96,7 +95,7 @@ def test_join_left(self):
96
95
tm .assert_numpy_array_equal (ridx , eridx )
97
96
98
97
# Join withRangeIndex
99
- other = Int64Index (np .arange (25 , 14 , - 1 ))
98
+ other = Index (np .arange (25 , 14 , - 1 , dtype = np . int64 ))
100
99
101
100
res , lidx , ridx = index .join (other , how = "left" , return_indexers = True )
102
101
@@ -106,15 +105,15 @@ def test_join_left(self):
106
105
tm .assert_numpy_array_equal (ridx , eridx )
107
106
108
107
def test_join_right (self ):
109
- # Join with Int64Index
108
+ # Join with Index[int64]
110
109
index = RangeIndex (start = 0 , stop = 20 , step = 2 )
111
- other = Int64Index (np .arange (25 , 14 , - 1 ))
110
+ other = Index (np .arange (25 , 14 , - 1 , dtype = np . int64 ))
112
111
113
112
res , lidx , ridx = index .join (other , how = "right" , return_indexers = True )
114
113
eres = other
115
114
elidx = np .array ([- 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , 9 , - 1 , 8 , - 1 ], dtype = np .intp )
116
115
117
- assert isinstance (other , Int64Index )
116
+ assert isinstance (other , Index ) and other . dtype == np . int64
118
117
tm .assert_index_equal (res , eres )
119
118
tm .assert_numpy_array_equal (lidx , elidx )
120
119
assert ridx is None
@@ -164,7 +163,7 @@ def test_join_non_unique(self):
164
163
165
164
res , lidx , ridx = index .join (other , return_indexers = True )
166
165
167
- eres = Int64Index ([0 , 2 , 4 , 4 , 6 , 8 , 10 , 12 , 14 , 16 , 18 ])
166
+ eres = Index ([0 , 2 , 4 , 4 , 6 , 8 , 10 , 12 , 14 , 16 , 18 ])
168
167
elidx = np .array ([0 , 1 , 2 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ], dtype = np .intp )
169
168
eridx = np .array ([- 1 , - 1 , 0 , 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 ], dtype = np .intp )
170
169
0 commit comments