Skip to content

Commit

Permalink
DEPR: Remove NumericIndex from pandas/io/ (#51058)
Browse files Browse the repository at this point in the history
  • Loading branch information
topper-123 committed Jan 30, 2023
1 parent eff0eee commit 780bec2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
3 changes: 1 addition & 2 deletions pandas/io/feather_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
)
from pandas.core.api import (
DataFrame,
NumericIndex,
RangeIndex,
)
from pandas.core.shared_docs import _shared_docs
Expand Down Expand Up @@ -69,7 +68,7 @@ def to_feather(
# validate that we have only a default index
# raise on anything else as we don't serialize the index

if not (isinstance(df.index, NumericIndex) and df.index.dtype == "int64"):
if not df.index.dtype == "int64":
typ = type(df.index)
raise ValueError(
f"feather does not support serializing {typ} "
Expand Down
17 changes: 6 additions & 11 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
concat,
isna,
)
from pandas.core.api import NumericIndex
from pandas.core.arrays import (
Categorical,
DatetimeArray,
Expand Down Expand Up @@ -2051,7 +2050,7 @@ def is_indexed(self) -> bool:

def convert(
self, values: np.ndarray, nan_rep, encoding: str, errors: str
) -> tuple[np.ndarray, np.ndarray] | tuple[DatetimeIndex, DatetimeIndex]:
) -> tuple[np.ndarray, np.ndarray] | tuple[Index, Index]:
"""
Convert the data from this selection to the appropriate pandas type.
"""
Expand Down Expand Up @@ -2244,13 +2243,9 @@ class GenericIndexCol(IndexCol):
def is_indexed(self) -> bool:
return False

# error: Return type "Tuple[NumericIndex, NumericIndex]" of "convert"
# incompatible with return type "Union[Tuple[ndarray[Any, Any],
# ndarray[Any, Any]], Tuple[DatetimeIndex, DatetimeIndex]]" in
# supertype "IndexCol"
def convert( # type: ignore[override]
def convert(
self, values: np.ndarray, nan_rep, encoding: str, errors: str
) -> tuple[NumericIndex, NumericIndex]:
) -> tuple[Index, Index]:
"""
Convert the data from this selection to the appropriate pandas type.
Expand All @@ -2263,7 +2258,7 @@ def convert( # type: ignore[override]
"""
assert isinstance(values, np.ndarray), type(values)

index = NumericIndex(np.arange(len(values)), dtype=np.int64)
index = Index(np.arange(len(values), dtype=np.int64))
return index, index

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

if (
(isinstance(index, NumericIndex) and is_integer_dtype(index))
(isinstance(index.dtype, np.dtype) and is_integer_dtype(index))
or needs_i8_conversion(index.dtype)
or is_bool_dtype(index.dtype)
):
# Includes NumericIndex, RangeIndex, DatetimeIndex, TimedeltaIndex, PeriodIndex,
# Includes Index, RangeIndex, DatetimeIndex, TimedeltaIndex, PeriodIndex,
# in which case "kind" is "integer", "integer", "datetime64",
# "timedelta64", and "integer", respectively.
return IndexCol(
Expand Down

0 comments on commit 780bec2

Please sign in to comment.