@@ -750,7 +750,10 @@ def test_union(self):
750
750
expected = Index (list ('ab' ), name = 'A' )
751
751
tm .assert_index_equal (union , expected )
752
752
753
- with tm .assert_produces_warning (RuntimeWarning ):
753
+ if PY3 :
754
+ with tm .assert_produces_warning (RuntimeWarning ):
755
+ firstCat = self .strIndex .union (self .dateIndex )
756
+ else :
754
757
firstCat = self .strIndex .union (self .dateIndex )
755
758
secondCat = self .strIndex .union (self .strIndex )
756
759
@@ -1309,29 +1312,26 @@ def test_drop(self):
1309
1312
expected = Index ([1 , 2 ])
1310
1313
tm .assert_index_equal (dropped , expected )
1311
1314
1312
- def test_tuple_union_bug (self ):
1313
- import pandas
1314
- import numpy as np
1315
-
1315
+ def test_tuples_intersection_union (self ):
1316
1316
aidx1 = np .array ([(1 , 'A' ), (2 , 'A' ), (1 , 'B' ), (2 , 'B' )],
1317
1317
dtype = [('num' , int ), ('let' , 'a1' )])
1318
1318
aidx2 = np .array ([(1 , 'A' ), (2 , 'A' ), (1 , 'B' ),
1319
1319
(2 , 'B' ), (1 , 'C' ), (2 , 'C' )],
1320
1320
dtype = [('num' , int ), ('let' , 'a1' )])
1321
1321
1322
- idx1 = pandas . Index (aidx1 )
1323
- idx2 = pandas . Index (aidx2 )
1322
+ idx1 = Index (aidx1 )
1323
+ idx2 = Index (aidx2 )
1324
1324
1325
- # intersection broken?
1325
+ # intersection
1326
1326
int_idx = idx1 .intersection (idx2 )
1327
+ expected = idx1 # pandas.Index(sorted(set(idx1) & set(idx2)))
1327
1328
# needs to be 1d like idx1 and idx2
1328
- expected = idx1 [:4 ] # pandas.Index(sorted(set(idx1) & set(idx2)))
1329
1329
assert int_idx .ndim == 1
1330
1330
tm .assert_index_equal (int_idx , expected )
1331
1331
1332
- # union broken
1332
+ # GH 17376 (union)
1333
1333
union_idx = idx1 .union (idx2 )
1334
- expected = idx2
1334
+ expected = idx2 . sort_values ()
1335
1335
assert union_idx .ndim == 1
1336
1336
tm .assert_index_equal (union_idx , expected )
1337
1337
@@ -1941,7 +1941,7 @@ def test_union_base(self):
1941
1941
tm .assert_index_equal (result , expected )
1942
1942
else :
1943
1943
result = first .union (second )
1944
- expected = Index (['b' , 2 , 'c ' , 0 , 'a ' , 1 ])
1944
+ expected = Index ([0 , 1 , 2 , 'a ' , 'b ' , 'c' ])
1945
1945
tm .assert_index_equal (result , expected )
1946
1946
1947
1947
# GH 10149
0 commit comments