@@ -390,6 +390,7 @@ def __new__(
390
390
)
391
391
392
392
from pandas .core .arrays import PandasArray
393
+ from pandas .core .indexes .numeric import NumIndex
393
394
from pandas .core .indexes .range import RangeIndex
394
395
395
396
name = maybe_extract_name (name , data , cls )
@@ -441,6 +442,8 @@ def __new__(
441
442
return Index ._simple_new (data , name = name )
442
443
443
444
# index-like
445
+ elif isinstance (data , NumIndex ) and dtype is None :
446
+ return NumIndex (data , name = name , copy = copy )
444
447
elif isinstance (data , (np .ndarray , Index , ABCSeries )):
445
448
446
449
if isinstance (data , ABCMultiIndex ):
@@ -2939,7 +2942,11 @@ def union(self, other, sort=None):
2939
2942
# float | [u]int -> float (the special case)
2940
2943
# <T> | <T> -> T
2941
2944
# <T> | <U> -> object
2942
- if not (is_integer_dtype (self .dtype ) and is_integer_dtype (other .dtype )):
2945
+ if is_float_dtype (self .dtype ) and is_float_dtype (other .dtype ):
2946
+ dtype = np .dtype ("object" )
2947
+ elif not (
2948
+ is_integer_dtype (self .dtype ) and is_integer_dtype (other .dtype )
2949
+ ):
2943
2950
dtype = np .dtype ("float64" )
2944
2951
else :
2945
2952
# one is int64 other is uint64
@@ -5465,8 +5472,9 @@ def map(self, mapper, na_action=None):
5465
5472
a MultiIndex will be returned.
5466
5473
"""
5467
5474
from pandas .core .indexes .multi import MultiIndex
5475
+ from pandas .core .indexes .numeric import NumIndex
5468
5476
5469
- new_values = super () ._map_values (mapper , na_action = na_action )
5477
+ new_values = self ._map_values (mapper , na_action = na_action )
5470
5478
5471
5479
attributes = self ._get_attributes_dict ()
5472
5480
@@ -5485,6 +5493,9 @@ def map(self, mapper, na_action=None):
5485
5493
# empty
5486
5494
attributes ["dtype" ] = self .dtype
5487
5495
5496
+ if isinstance (self , NumIndex ):
5497
+ return NumIndex (new_values , ** attributes )
5498
+
5488
5499
return Index (new_values , ** attributes )
5489
5500
5490
5501
# TODO: De-duplicate with map, xref GH#32349
0 commit comments