47
47
from pandas .core .construction import extract_array
48
48
import pandas .core .indexes .base as ibase
49
49
from pandas .core .indexes .base import maybe_extract_name
50
- from pandas .core .indexes .numeric import (
51
- Int64Index ,
52
- NumericIndex ,
53
- )
50
+ from pandas .core .indexes .numeric import NumericIndex
54
51
from pandas .core .ops .common import unpack_zerodim_and_defer
55
52
56
53
if TYPE_CHECKING :
@@ -63,8 +60,8 @@ class RangeIndex(NumericIndex):
63
60
"""
64
61
Immutable Index implementing a monotonic integer range.
65
62
66
- RangeIndex is a memory-saving special case of Int64Index limited to
67
- representing monotonic ranges. Using RangeIndex may in some instances
63
+ RangeIndex is a memory-saving special case of an Index limited to representing
64
+ monotonic ranges with a 64-bit dtype . Using RangeIndex may in some instances
68
65
improve computing speed.
69
66
70
67
This is the default index type used
@@ -96,7 +93,6 @@ class RangeIndex(NumericIndex):
96
93
See Also
97
94
--------
98
95
Index : The base pandas Index type.
99
- Int64Index : Index of int64 data.
100
96
"""
101
97
102
98
_typ = "rangeindex"
@@ -184,7 +180,7 @@ def _simple_new( # type: ignore[override]
184
180
185
181
# --------------------------------------------------------------------
186
182
187
- # error: Return type "Type[Int64Index ]" of "_constructor" incompatible with return
183
+ # error: Return type "Type[NumericIndex ]" of "_constructor" incompatible with return
188
184
# type "Type[RangeIndex]" in supertype "Index"
189
185
@cache_readonly
190
186
def _constructor (self ) -> type [NumericIndex ]: # type: ignore[override]
@@ -330,7 +326,7 @@ def inferred_type(self) -> str:
330
326
# --------------------------------------------------------------------
331
327
# Indexing Methods
332
328
333
- @doc (Int64Index .get_loc )
329
+ @doc (NumericIndex .get_loc )
334
330
def get_loc (self , key ):
335
331
if is_integer (key ) or (is_float (key ) and key .is_integer ()):
336
332
new_key = int (key )
@@ -376,18 +372,18 @@ def _get_indexer(
376
372
def tolist (self ) -> list [int ]:
377
373
return list (self ._range )
378
374
379
- @doc (Int64Index .__iter__ )
375
+ @doc (NumericIndex .__iter__ )
380
376
def __iter__ (self ) -> Iterator [int ]:
381
377
yield from self ._range
382
378
383
- @doc (Int64Index ._shallow_copy )
379
+ @doc (NumericIndex ._shallow_copy )
384
380
def _shallow_copy (self , values , name : Hashable = no_default ):
385
381
name = self .name if name is no_default else name
386
382
387
383
if values .dtype .kind == "f" :
388
384
return NumericIndex (values , name = name , dtype = np .float64 )
389
385
# GH 46675 & 43885: If values is equally spaced, return a
390
- # more memory-compact RangeIndex instead of Int64Index
386
+ # more memory-compact RangeIndex instead of Index with 64-bit dtype
391
387
unique_diffs = unique_deltas (values )
392
388
if len (unique_diffs ) == 1 and unique_diffs [0 ] != 0 :
393
389
diff = unique_diffs [0 ]
@@ -401,7 +397,7 @@ def _view(self: RangeIndex) -> RangeIndex:
401
397
result ._cache = self ._cache
402
398
return result
403
399
404
- @doc (Int64Index .copy )
400
+ @doc (NumericIndex .copy )
405
401
def copy (self , name : Hashable = None , deep : bool = False ):
406
402
name = self ._validate_names (name = name , deep = deep )[0 ]
407
403
new_index = self ._rename (name = name )
@@ -516,7 +512,6 @@ def _intersection(self, other: Index, sort: bool = False):
516
512
# caller is responsible for checking self and other are both non-empty
517
513
518
514
if not isinstance (other , RangeIndex ):
519
- # Int64Index
520
515
return super ()._intersection (other , sort = sort )
521
516
522
517
first = self ._range [::- 1 ] if self .step < 0 else self ._range
@@ -603,10 +598,10 @@ def _union(self, other: Index, sort):
603
598
sort : False or None, default None
604
599
Whether to sort (monotonically increasing) the resulting index.
605
600
``sort=None`` returns a ``RangeIndex`` if possible or a sorted
606
- ``Int64Index`` if not.
601
+ ``Index`` with a int64 dtype if not.
607
602
``sort=False`` can return a ``RangeIndex`` if self is monotonically
608
603
increasing and other is fully contained in self. Otherwise, returns
609
- an unsorted ``Int64Index``
604
+ an unsorted ``Index`` with an int64 dtype.
610
605
611
606
Returns
612
607
-------
@@ -818,9 +813,9 @@ def _concat(self, indexes: list[Index], name: Hashable) -> Index:
818
813
Overriding parent method for the case of all RangeIndex instances.
819
814
820
815
When all members of "indexes" are of type RangeIndex: result will be
821
- RangeIndex if possible, Int64Index otherwise. E.g.:
816
+ RangeIndex if possible, Index with a int64 dtype otherwise. E.g.:
822
817
indexes = [RangeIndex(3), RangeIndex(3, 6)] -> RangeIndex(6)
823
- indexes = [RangeIndex(3), RangeIndex(4, 6)] -> Int64Index ([0,1,2,4,5])
818
+ indexes = [RangeIndex(3), RangeIndex(4, 6)] -> Index ([0,1,2,4,5], dtype='int64' )
824
819
"""
825
820
if not all (isinstance (x , RangeIndex ) for x in indexes ):
826
821
return super ()._concat (indexes , name )
0 commit comments