Skip to content

Commit 780bec2

Browse files
authored
DEPR: Remove NumericIndex from pandas/io/ (#51058)
1 parent eff0eee commit 780bec2

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

pandas/io/feather_format.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
)
2525
from pandas.core.api import (
2626
DataFrame,
27-
NumericIndex,
2827
RangeIndex,
2928
)
3029
from pandas.core.shared_docs import _shared_docs
@@ -69,7 +68,7 @@ def to_feather(
6968
# validate that we have only a default index
7069
# raise on anything else as we don't serialize the index
7170

72-
if not (isinstance(df.index, NumericIndex) and df.index.dtype == "int64"):
71+
if not df.index.dtype == "int64":
7372
typ = type(df.index)
7473
raise ValueError(
7574
f"feather does not support serializing {typ} "

pandas/io/pytables.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
concat,
9191
isna,
9292
)
93-
from pandas.core.api import NumericIndex
9493
from pandas.core.arrays import (
9594
Categorical,
9695
DatetimeArray,
@@ -2051,7 +2050,7 @@ def is_indexed(self) -> bool:
20512050

20522051
def convert(
20532052
self, values: np.ndarray, nan_rep, encoding: str, errors: str
2054-
) -> tuple[np.ndarray, np.ndarray] | tuple[DatetimeIndex, DatetimeIndex]:
2053+
) -> tuple[np.ndarray, np.ndarray] | tuple[Index, Index]:
20552054
"""
20562055
Convert the data from this selection to the appropriate pandas type.
20572056
"""
@@ -2244,13 +2243,9 @@ class GenericIndexCol(IndexCol):
22442243
def is_indexed(self) -> bool:
22452244
return False
22462245

2247-
# error: Return type "Tuple[NumericIndex, NumericIndex]" of "convert"
2248-
# incompatible with return type "Union[Tuple[ndarray[Any, Any],
2249-
# ndarray[Any, Any]], Tuple[DatetimeIndex, DatetimeIndex]]" in
2250-
# supertype "IndexCol"
2251-
def convert( # type: ignore[override]
2246+
def convert(
22522247
self, values: np.ndarray, nan_rep, encoding: str, errors: str
2253-
) -> tuple[NumericIndex, NumericIndex]:
2248+
) -> tuple[Index, Index]:
22542249
"""
22552250
Convert the data from this selection to the appropriate pandas type.
22562251
@@ -2263,7 +2258,7 @@ def convert( # type: ignore[override]
22632258
"""
22642259
assert isinstance(values, np.ndarray), type(values)
22652260

2266-
index = NumericIndex(np.arange(len(values)), dtype=np.int64)
2261+
index = Index(np.arange(len(values), dtype=np.int64))
22672262
return index, index
22682263

22692264
def set_attr(self) -> None:
@@ -4866,11 +4861,11 @@ def _convert_index(name: str, index: Index, encoding: str, errors: str) -> Index
48664861
atom = DataIndexableCol._get_atom(converted)
48674862

48684863
if (
4869-
(isinstance(index, NumericIndex) and is_integer_dtype(index))
4864+
(isinstance(index.dtype, np.dtype) and is_integer_dtype(index))
48704865
or needs_i8_conversion(index.dtype)
48714866
or is_bool_dtype(index.dtype)
48724867
):
4873-
# Includes NumericIndex, RangeIndex, DatetimeIndex, TimedeltaIndex, PeriodIndex,
4868+
# Includes Index, RangeIndex, DatetimeIndex, TimedeltaIndex, PeriodIndex,
48744869
# in which case "kind" is "integer", "integer", "datetime64",
48754870
# "timedelta64", and "integer", respectively.
48764871
return IndexCol(

0 commit comments

Comments
 (0)