Skip to content

Commit be5519f

Browse files
committed
remove Int64Index
1 parent a3a2129 commit be5519f

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

pandas/core/indexes/range.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@
4747
from pandas.core.construction import extract_array
4848
import pandas.core.indexes.base as ibase
4949
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
5451
from pandas.core.ops.common import unpack_zerodim_and_defer
5552

5653
if TYPE_CHECKING:
@@ -63,8 +60,8 @@ class RangeIndex(NumericIndex):
6360
"""
6461
Immutable Index implementing a monotonic integer range.
6562
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
6865
improve computing speed.
6966
7067
This is the default index type used
@@ -96,7 +93,6 @@ class RangeIndex(NumericIndex):
9693
See Also
9794
--------
9895
Index : The base pandas Index type.
99-
Int64Index : Index of int64 data.
10096
"""
10197

10298
_typ = "rangeindex"
@@ -184,7 +180,7 @@ def _simple_new( # type: ignore[override]
184180

185181
# --------------------------------------------------------------------
186182

187-
# error: Return type "Type[Int64Index]" of "_constructor" incompatible with return
183+
# error: Return type "Type[NumericIndex]" of "_constructor" incompatible with return
188184
# type "Type[RangeIndex]" in supertype "Index"
189185
@cache_readonly
190186
def _constructor(self) -> type[NumericIndex]: # type: ignore[override]
@@ -330,7 +326,7 @@ def inferred_type(self) -> str:
330326
# --------------------------------------------------------------------
331327
# Indexing Methods
332328

333-
@doc(Int64Index.get_loc)
329+
@doc(NumericIndex.get_loc)
334330
def get_loc(self, key):
335331
if is_integer(key) or (is_float(key) and key.is_integer()):
336332
new_key = int(key)
@@ -376,18 +372,18 @@ def _get_indexer(
376372
def tolist(self) -> list[int]:
377373
return list(self._range)
378374

379-
@doc(Int64Index.__iter__)
375+
@doc(NumericIndex.__iter__)
380376
def __iter__(self) -> Iterator[int]:
381377
yield from self._range
382378

383-
@doc(Int64Index._shallow_copy)
379+
@doc(NumericIndex._shallow_copy)
384380
def _shallow_copy(self, values, name: Hashable = no_default):
385381
name = self.name if name is no_default else name
386382

387383
if values.dtype.kind == "f":
388384
return NumericIndex(values, name=name, dtype=np.float64)
389385
# 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
391387
unique_diffs = unique_deltas(values)
392388
if len(unique_diffs) == 1 and unique_diffs[0] != 0:
393389
diff = unique_diffs[0]
@@ -401,7 +397,7 @@ def _view(self: RangeIndex) -> RangeIndex:
401397
result._cache = self._cache
402398
return result
403399

404-
@doc(Int64Index.copy)
400+
@doc(NumericIndex.copy)
405401
def copy(self, name: Hashable = None, deep: bool = False):
406402
name = self._validate_names(name=name, deep=deep)[0]
407403
new_index = self._rename(name=name)
@@ -516,7 +512,6 @@ def _intersection(self, other: Index, sort: bool = False):
516512
# caller is responsible for checking self and other are both non-empty
517513

518514
if not isinstance(other, RangeIndex):
519-
# Int64Index
520515
return super()._intersection(other, sort=sort)
521516

522517
first = self._range[::-1] if self.step < 0 else self._range
@@ -603,10 +598,10 @@ def _union(self, other: Index, sort):
603598
sort : False or None, default None
604599
Whether to sort (monotonically increasing) the resulting index.
605600
``sort=None`` returns a ``RangeIndex`` if possible or a sorted
606-
``Int64Index`` if not.
601+
``Index`` with a int64 dtype if not.
607602
``sort=False`` can return a ``RangeIndex`` if self is monotonically
608603
increasing and other is fully contained in self. Otherwise, returns
609-
an unsorted ``Int64Index``
604+
an unsorted ``Index`` with an int64 dtype.
610605
611606
Returns
612607
-------
@@ -818,9 +813,9 @@ def _concat(self, indexes: list[Index], name: Hashable) -> Index:
818813
Overriding parent method for the case of all RangeIndex instances.
819814
820815
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.:
822817
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')
824819
"""
825820
if not all(isinstance(x, RangeIndex) for x in indexes):
826821
return super()._concat(indexes, name)

0 commit comments

Comments
 (0)