@@ -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
@@ -5462,8 +5469,9 @@ def map(self, mapper, na_action=None):
5462
5469
a MultiIndex will be returned.
5463
5470
"""
5464
5471
from pandas .core .indexes .multi import MultiIndex
5472
+ from pandas .core .indexes .numeric import NumIndex
5465
5473
5466
- new_values = super () ._map_values (mapper , na_action = na_action )
5474
+ new_values = self ._map_values (mapper , na_action = na_action )
5467
5475
5468
5476
attributes = self ._get_attributes_dict ()
5469
5477
@@ -5482,6 +5490,9 @@ def map(self, mapper, na_action=None):
5482
5490
# empty
5483
5491
attributes ["dtype" ] = self .dtype
5484
5492
5493
+ if isinstance (self , NumIndex ):
5494
+ return NumIndex (new_values , ** attributes )
5495
+
5485
5496
return Index (new_values , ** attributes )
5486
5497
5487
5498
# TODO: De-duplicate with map, xref GH#32349
0 commit comments