Skip to content

Commit 1c17d94

Browse files
authored
DEPR: Remove (Int|UInt|Float)64Index (#50908)
* DEPR: Remove (Int|UInt|Float)64Index * fix pre-commit * fix stuff
1 parent e5021de commit 1c17d94

18 files changed

+38
-197
lines changed

pandas/_testing/asserters.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ def assert_almost_equal(
7575
right : object
7676
check_dtype : bool or {'equiv'}, default 'equiv'
7777
Check dtype if both a and b are the same type. If 'equiv' is passed in,
78-
then `RangeIndex` and `Int64Index` are also considered equivalent
79-
when doing type checking.
78+
then `RangeIndex` and `NumericIndex` with int64 dtype are also considered
79+
equivalent when doing type checking.
8080
rtol : float, default 1e-5
8181
Relative tolerance.
8282
@@ -197,7 +197,7 @@ def assert_index_equal(
197197
exact : bool or {'equiv'}, default 'equiv'
198198
Whether to check the Index class, dtype and inferred_type
199199
are identical. If 'equiv', then RangeIndex can be substituted for
200-
Int64Index as well.
200+
NumericIndex with an int64 dtype as well.
201201
check_names : bool, default True
202202
Whether to check the names attribute.
203203
check_exact : bool, default True
@@ -511,7 +511,7 @@ def assert_interval_array_equal(
511511
exact : bool or {'equiv'}, default 'equiv'
512512
Whether to check the Index class, dtype and inferred_type
513513
are identical. If 'equiv', then RangeIndex can be substituted for
514-
Int64Index as well.
514+
NumericIndex with an int64 dtype as well.
515515
obj : str, default 'IntervalArray'
516516
Specify object name being compared, internally used to show appropriate
517517
assertion message

pandas/compat/pickle_compat.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def load_reduce(self):
9494
("pandas.indexes.base", "_new_Index"): ("pandas.core.indexes.base", "_new_Index"),
9595
("pandas.indexes.base", "Index"): ("pandas.core.indexes.base", "Index"),
9696
("pandas.indexes.numeric", "Int64Index"): (
97-
"pandas.core.indexes.numeric",
98-
"Int64Index",
97+
"pandas.core.indexes.base",
98+
"Index", # updated in 50775
9999
),
100100
("pandas.indexes.range", "RangeIndex"): ("pandas.core.indexes.range", "RangeIndex"),
101101
("pandas.indexes.multi", "MultiIndex"): ("pandas.core.indexes.multi", "MultiIndex"),
@@ -119,7 +119,7 @@ def load_reduce(self):
119119
"TimedeltaIndex",
120120
),
121121
("pandas.indexes.numeric", "Float64Index"): (
122-
"pandas.core.indexes.numeric",
122+
"pandas.core.indexes.base",
123123
"Index", # updated in 50775
124124
),
125125
# 50775, remove Int64Index, UInt64Index & Float64Index from codabase

pandas/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def multiindex_year_month_day_dataframe_random_data():
520520
"""
521521
tdf = tm.makeTimeDataFrame(100)
522522
ymd = tdf.groupby([lambda x: x.year, lambda x: x.month, lambda x: x.day]).sum()
523-
# use Int64Index, to make sure things work
523+
# use int64 Index, to make sure things work
524524
ymd.index = ymd.index.set_levels([lev.astype("i8") for lev in ymd.index.levels])
525525
ymd.index.set_names(["year", "month", "day"], inplace=True)
526526
return ymd

pandas/core/algorithms.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ def __init__(self, obj: DataFrame, n: int, keep: str, columns: IndexLabel) -> No
13051305

13061306
def compute(self, method: str) -> DataFrame:
13071307

1308-
from pandas.core.api import Int64Index
1308+
from pandas.core.api import NumericIndex
13091309

13101310
n = self.n
13111311
frame = self.obj
@@ -1333,7 +1333,7 @@ def get_indexer(current_indexer, other_indexer):
13331333
original_index = frame.index
13341334
cur_frame = frame = frame.reset_index(drop=True)
13351335
cur_n = n
1336-
indexer = Int64Index([])
1336+
indexer = NumericIndex([], dtype=np.int64)
13371337

13381338
for i, column in enumerate(columns):
13391339
# For each column we apply method to cur_frame[column].

pandas/core/api.py

-6
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,13 @@
5151
from pandas.core.indexes.api import (
5252
CategoricalIndex,
5353
DatetimeIndex,
54-
Float64Index,
5554
Index,
56-
Int64Index,
5755
IntervalIndex,
5856
MultiIndex,
5957
NumericIndex,
6058
PeriodIndex,
6159
RangeIndex,
6260
TimedeltaIndex,
63-
UInt64Index,
6461
)
6562
from pandas.core.indexes.datetimes import (
6663
bdate_range,
@@ -101,14 +98,12 @@
10198
"Flags",
10299
"Float32Dtype",
103100
"Float64Dtype",
104-
"Float64Index",
105101
"Grouper",
106102
"Index",
107103
"IndexSlice",
108104
"Int16Dtype",
109105
"Int32Dtype",
110106
"Int64Dtype",
111-
"Int64Index",
112107
"Int8Dtype",
113108
"Interval",
114109
"IntervalDtype",
@@ -141,7 +136,6 @@
141136
"UInt16Dtype",
142137
"UInt32Dtype",
143138
"UInt64Dtype",
144-
"UInt64Index",
145139
"UInt8Dtype",
146140
"unique",
147141
"value_counts",

pandas/core/arrays/timedeltas.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -726,10 +726,10 @@ def total_seconds(self) -> npt.NDArray[np.float64]:
726726
727727
Returns
728728
-------
729-
ndarray, Float64Index or Series
729+
ndarray, Index or Series
730730
When the calling object is a TimedeltaArray, the return type
731731
is ndarray. When the calling object is a TimedeltaIndex,
732-
the return type is a Float64Index. When the calling object
732+
the return type is an Index with a float64 dtype. When the calling object
733733
is a Series, the return type is Series of type `float64` whose
734734
index is the same as the original.
735735

pandas/core/frame.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -10870,11 +10870,7 @@ def quantile(
1087010870
f"Invalid method: {method}. Method must be in {valid_method}."
1087110871
)
1087210872
if method == "single":
10873-
# error: Argument "qs" to "quantile" of "BlockManager" has incompatible type
10874-
# "Index"; expected "Float64Index"
10875-
res = data._mgr.quantile(
10876-
qs=q, axis=1, interpolation=interpolation # type: ignore[arg-type]
10877-
)
10873+
res = data._mgr.quantile(qs=q, axis=1, interpolation=interpolation)
1087810874
elif method == "table":
1087910875
valid_interpolation = {"nearest", "lower", "higher"}
1088010876
if interpolation not in valid_interpolation:

pandas/core/groupby/grouper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ def is_in_axis(key) -> bool:
880880
try:
881881
items.get_loc(key)
882882
except (KeyError, TypeError, InvalidIndexError):
883-
# TypeError shows up here if we pass e.g. Int64Index
883+
# TypeError shows up here if we pass e.g. an Index
884884
return False
885885

886886
return True

pandas/core/indexes/api.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@
2626
from pandas.core.indexes.datetimes import DatetimeIndex
2727
from pandas.core.indexes.interval import IntervalIndex
2828
from pandas.core.indexes.multi import MultiIndex
29-
from pandas.core.indexes.numeric import (
30-
Float64Index,
31-
Int64Index,
32-
NumericIndex,
33-
UInt64Index,
34-
)
29+
from pandas.core.indexes.numeric import NumericIndex
3530
from pandas.core.indexes.period import PeriodIndex
3631
from pandas.core.indexes.range import RangeIndex
3732
from pandas.core.indexes.timedeltas import TimedeltaIndex
@@ -52,12 +47,9 @@
5247
"Index",
5348
"MultiIndex",
5449
"NumericIndex",
55-
"Float64Index",
56-
"Int64Index",
5750
"CategoricalIndex",
5851
"IntervalIndex",
5952
"RangeIndex",
60-
"UInt64Index",
6153
"InvalidIndexError",
6254
"TimedeltaIndex",
6355
"PeriodIndex",

pandas/core/indexes/base.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,6 @@ class Index(IndexOpsMixin, PandasObject):
296296
TimedeltaIndex : Index of timedelta64 data.
297297
PeriodIndex : Index of Period data.
298298
NumericIndex : Index of numpy int/uint/float data.
299-
Int64Index : Index of purely int64 labels (deprecated).
300-
UInt64Index : Index of purely uint64 labels (deprecated).
301-
Float64Index : Index of purely float64 labels (deprecated).
302299
303300
Notes
304301
-----
@@ -498,7 +495,7 @@ def __new__(
498495

499496
klass = cls._dtype_to_subclass(arr.dtype)
500497

501-
# _ensure_array _may_ be unnecessary once Int64Index etc are gone
498+
# _ensure_array _may_ be unnecessary once NumericIndex etc are gone
502499
arr = klass._ensure_array(arr, arr.dtype, copy=False)
503500
return klass._simple_new(arr, name)
504501

@@ -1026,7 +1023,7 @@ def take(
10261023
taken = values.take(
10271024
indices, allow_fill=allow_fill, fill_value=self._na_value
10281025
)
1029-
# _constructor so RangeIndex->Int64Index
1026+
# _constructor so RangeIndex-> Index with an int64 dtype
10301027
return self._constructor._simple_new(taken, name=self.name)
10311028

10321029
@final
@@ -1097,7 +1094,7 @@ def repeat(self, repeats, axis=None):
10971094
nv.validate_repeat((), {"axis": axis})
10981095
res_values = self._values.repeat(repeats)
10991096

1100-
# _constructor so RangeIndex->Int64Index
1097+
# _constructor so RangeIndex-> Index with an int64 dtype
11011098
return self._constructor._simple_new(res_values, name=self.name)
11021099

11031100
# --------------------------------------------------------------------
@@ -6228,7 +6225,7 @@ def _maybe_cast_slice_bound(self, label, side: str_t):
62286225
"""
62296226

62306227
# We are a plain index here (sub-class override this method if they
6231-
# wish to have special treatment for floats/ints, e.g. Float64Index and
6228+
# wish to have special treatment for floats/ints, e.g. NumericIndex and
62326229
# datetimelike Indexes
62336230
# Special case numeric EA Indexes, since they are not handled by NumericIndex
62346231

@@ -6442,7 +6439,7 @@ def delete(self: _IndexT, loc) -> _IndexT:
64426439
else:
64436440
res_values = values.delete(loc)
64446441

6445-
# _constructor so RangeIndex->Int64Index
6442+
# _constructor so RangeIndex-> Index with an int64 dtype
64466443
return self._constructor._simple_new(res_values, name=self.name)
64476444

64486445
def insert(self, loc: int, item) -> Index:

pandas/core/indexes/datetimes.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
if TYPE_CHECKING:
6464
from pandas.core.api import (
6565
DataFrame,
66-
Float64Index,
66+
NumericIndex,
6767
PeriodIndex,
6868
)
6969

@@ -284,11 +284,11 @@ def to_period(self, freq=None) -> PeriodIndex:
284284
return PeriodIndex._simple_new(arr, name=self.name)
285285

286286
@doc(DatetimeArray.to_julian_date)
287-
def to_julian_date(self) -> Float64Index:
288-
from pandas.core.indexes.api import Float64Index
287+
def to_julian_date(self) -> NumericIndex:
288+
from pandas.core.indexes.api import NumericIndex
289289

290290
arr = self._data.to_julian_date()
291-
return Float64Index._simple_new(arr, name=self.name)
291+
return NumericIndex._simple_new(arr, name=self.name)
292292

293293
@doc(DatetimeArray.isocalendar)
294294
def isocalendar(self) -> DataFrame:

pandas/core/indexes/interval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def _maybe_convert_i8(self, key):
520520
-------
521521
scalar or list-like
522522
The original key if no conversion occurred, int if converted scalar,
523-
Int64Index if converted list-like.
523+
Index with an int64 dtype if converted list-like.
524524
"""
525525
if is_list_like(key):
526526
key = ensure_index(key)

pandas/core/indexes/multi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,7 @@ def get_level_values(self, level):
16421642
level_1 int64
16431643
dtype: object
16441644
>>> pd.MultiIndex.from_arrays([[1, None, 2], [3, 4, 5]]).get_level_values(0)
1645-
Float64Index([1.0, nan, 2.0], dtype='float64')
1645+
NumericIndex([1.0, nan, 2.0], dtype='float64')
16461646
"""
16471647
level = self._get_level_number(level)
16481648
values = self._get_level_values(level)

0 commit comments

Comments
 (0)