55
66from datetime import datetime
77import operator
8- import pandas as pd
8+
99import numpy as np
1010import pytest
1111
@@ -64,20 +64,22 @@ def index_flat2(index_flat):
6464
6565def test_union_same_types (index ):
6666 # mixed int string
67- if index .equals (pd . Index ([0 , "a" , 1 , "b" , 2 , "c" ])):
67+ if index .equals (Index ([0 , "a" , 1 , "b" , 2 , "c" ])):
6868 index = index .astype (str )
6969
7070 idx1 = index .sort_values ()
7171 idx2 = index .sort_values ()
7272 assert idx1 .union (idx2 , sort = False ).dtype == idx1 .dtype
7373
74+
7475def test_union_different_types (index_flat , index_flat2 , request ):
7576 idx1 = index_flat
7677 idx2 = index_flat2
7778
7879 # Special handling for mixed int-string types
79- if idx1 .equals (pd .Index ([0 , "a" , 1 , "b" , 2 , "c" ])) or \
80- idx2 .equals (pd .Index ([0 , "a" , 1 , "b" , 2 , "c" ])):
80+ if idx1 .equals (Index ([0 , "a" , 1 , "b" , 2 , "c" ])) or idx2 .equals (
81+ Index ([0 , "a" , 1 , "b" , 2 , "c" ])
82+ ):
8183 idx1 = idx1 .astype (str )
8284 idx2 = idx2 .astype (str )
8385
@@ -130,6 +132,7 @@ def test_union_different_types(index_flat, index_flat2, request):
130132 assert res1 .dtype == common_dtype
131133 assert res2 .dtype == common_dtype
132134
135+
133136@pytest .mark .parametrize (
134137 "idx1,idx2" ,
135138 [
@@ -234,14 +237,13 @@ def test_intersection_base(self, index):
234237
235238 @pytest .mark .filterwarnings (r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning" )
236239 def test_union_base (self , index ):
237-
238240 if index .inferred_type in ["mixed" , "mixed-integer" ]:
239241 pytest .skip ("Mixed-type Index not orderable; union fails" )
240242
241243 index = index .unique ()
242244
243245 # Mixed int string
244- if index .equals (pd . Index ([0 , "a" , 1 , "b" , 2 , "c" ])):
246+ if index .equals (Index ([0 , "a" , 1 , "b" , 2 , "c" ])):
245247 index = index .astype (str )
246248
247249 first = index [3 :]
@@ -296,7 +298,6 @@ def test_difference_base(self, sort, index):
296298
297299 @pytest .mark .filterwarnings (r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning" )
298300 def test_symmetric_difference (self , index , using_infer_string , request ):
299-
300301 if (
301302 using_infer_string
302303 and index .dtype == "object"
@@ -311,7 +312,7 @@ def test_symmetric_difference(self, index, using_infer_string, request):
311312 # index fixture has e.g. an index of bools that does not satisfy this,
312313 # another with [0, 0, 1, 1, 2, 2]
313314 pytest .skip ("Index values no not satisfy test condition." )
314- if index .equals (pd . Index ([0 , "a" , 1 , "b" , 2 , "c" ])):
315+ if index .equals (Index ([0 , "a" , 1 , "b" , 2 , "c" ])):
315316 index = index .astype (str )
316317 first = index [1 :]
317318 second = index [:- 1 ]
@@ -920,8 +921,9 @@ def test_symmetric_difference_mi(self, sort):
920921 index2 = MultiIndex .from_tuples ([("foo" , 1 ), ("bar" , 3 )])
921922
922923 def has_mixed_types (level ):
923- return any (isinstance (x , str ) for x in level ) and \
924- any (isinstance (x , int ) for x in level )
924+ return any (isinstance (x , str ) for x in level ) and any (
925+ isinstance (x , int ) for x in level
926+ )
925927
926928 for idx in [index1 , index2 ]:
927929 for lvl in range (idx .nlevels ):
0 commit comments