Skip to content

Commit

Permalink
DEPR: Remove (Int|UInt|Float)64Index (pandas-dev#50908)
Browse files Browse the repository at this point in the history
* DEPR: Remove (Int|UInt|Float)64Index

* fix pre-commit

* fix stuff
  • Loading branch information
topper-123 authored and iofall committed Jan 23, 2023
1 parent 2ce6f81 commit f298778
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 197 deletions.
8 changes: 4 additions & 4 deletions pandas/_testing/asserters.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def assert_almost_equal(
right : object
check_dtype : bool or {'equiv'}, default 'equiv'
Check dtype if both a and b are the same type. If 'equiv' is passed in,
then `RangeIndex` and `Int64Index` are also considered equivalent
when doing type checking.
then `RangeIndex` and `NumericIndex` with int64 dtype are also considered
equivalent when doing type checking.
rtol : float, default 1e-5
Relative tolerance.
Expand Down Expand Up @@ -197,7 +197,7 @@ def assert_index_equal(
exact : bool or {'equiv'}, default 'equiv'
Whether to check the Index class, dtype and inferred_type
are identical. If 'equiv', then RangeIndex can be substituted for
Int64Index as well.
NumericIndex with an int64 dtype as well.
check_names : bool, default True
Whether to check the names attribute.
check_exact : bool, default True
Expand Down Expand Up @@ -511,7 +511,7 @@ def assert_interval_array_equal(
exact : bool or {'equiv'}, default 'equiv'
Whether to check the Index class, dtype and inferred_type
are identical. If 'equiv', then RangeIndex can be substituted for
Int64Index as well.
NumericIndex with an int64 dtype as well.
obj : str, default 'IntervalArray'
Specify object name being compared, internally used to show appropriate
assertion message
Expand Down
6 changes: 3 additions & 3 deletions pandas/compat/pickle_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def load_reduce(self):
("pandas.indexes.base", "_new_Index"): ("pandas.core.indexes.base", "_new_Index"),
("pandas.indexes.base", "Index"): ("pandas.core.indexes.base", "Index"),
("pandas.indexes.numeric", "Int64Index"): (
"pandas.core.indexes.numeric",
"Int64Index",
"pandas.core.indexes.base",
"Index", # updated in 50775
),
("pandas.indexes.range", "RangeIndex"): ("pandas.core.indexes.range", "RangeIndex"),
("pandas.indexes.multi", "MultiIndex"): ("pandas.core.indexes.multi", "MultiIndex"),
Expand All @@ -119,7 +119,7 @@ def load_reduce(self):
"TimedeltaIndex",
),
("pandas.indexes.numeric", "Float64Index"): (
"pandas.core.indexes.numeric",
"pandas.core.indexes.base",
"Index", # updated in 50775
),
# 50775, remove Int64Index, UInt64Index & Float64Index from codabase
Expand Down
2 changes: 1 addition & 1 deletion pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def multiindex_year_month_day_dataframe_random_data():
"""
tdf = tm.makeTimeDataFrame(100)
ymd = tdf.groupby([lambda x: x.year, lambda x: x.month, lambda x: x.day]).sum()
# use Int64Index, to make sure things work
# use int64 Index, to make sure things work
ymd.index = ymd.index.set_levels([lev.astype("i8") for lev in ymd.index.levels])
ymd.index.set_names(["year", "month", "day"], inplace=True)
return ymd
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ def __init__(self, obj: DataFrame, n: int, keep: str, columns: IndexLabel) -> No

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

from pandas.core.api import Int64Index
from pandas.core.api import NumericIndex

n = self.n
frame = self.obj
Expand Down Expand Up @@ -1333,7 +1333,7 @@ def get_indexer(current_indexer, other_indexer):
original_index = frame.index
cur_frame = frame = frame.reset_index(drop=True)
cur_n = n
indexer = Int64Index([])
indexer = NumericIndex([], dtype=np.int64)

for i, column in enumerate(columns):
# For each column we apply method to cur_frame[column].
Expand Down
6 changes: 0 additions & 6 deletions pandas/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,13 @@
from pandas.core.indexes.api import (
CategoricalIndex,
DatetimeIndex,
Float64Index,
Index,
Int64Index,
IntervalIndex,
MultiIndex,
NumericIndex,
PeriodIndex,
RangeIndex,
TimedeltaIndex,
UInt64Index,
)
from pandas.core.indexes.datetimes import (
bdate_range,
Expand Down Expand Up @@ -101,14 +98,12 @@
"Flags",
"Float32Dtype",
"Float64Dtype",
"Float64Index",
"Grouper",
"Index",
"IndexSlice",
"Int16Dtype",
"Int32Dtype",
"Int64Dtype",
"Int64Index",
"Int8Dtype",
"Interval",
"IntervalDtype",
Expand Down Expand Up @@ -141,7 +136,6 @@
"UInt16Dtype",
"UInt32Dtype",
"UInt64Dtype",
"UInt64Index",
"UInt8Dtype",
"unique",
"value_counts",
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/arrays/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,10 +726,10 @@ def total_seconds(self) -> npt.NDArray[np.float64]:
Returns
-------
ndarray, Float64Index or Series
ndarray, Index or Series
When the calling object is a TimedeltaArray, the return type
is ndarray. When the calling object is a TimedeltaIndex,
the return type is a Float64Index. When the calling object
the return type is an Index with a float64 dtype. When the calling object
is a Series, the return type is Series of type `float64` whose
index is the same as the original.
Expand Down
6 changes: 1 addition & 5 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -10870,11 +10870,7 @@ def quantile(
f"Invalid method: {method}. Method must be in {valid_method}."
)
if method == "single":
# error: Argument "qs" to "quantile" of "BlockManager" has incompatible type
# "Index"; expected "Float64Index"
res = data._mgr.quantile(
qs=q, axis=1, interpolation=interpolation # type: ignore[arg-type]
)
res = data._mgr.quantile(qs=q, axis=1, interpolation=interpolation)
elif method == "table":
valid_interpolation = {"nearest", "lower", "higher"}
if interpolation not in valid_interpolation:
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/groupby/grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ def is_in_axis(key) -> bool:
try:
items.get_loc(key)
except (KeyError, TypeError, InvalidIndexError):
# TypeError shows up here if we pass e.g. Int64Index
# TypeError shows up here if we pass e.g. an Index
return False

return True
Expand Down
10 changes: 1 addition & 9 deletions pandas/core/indexes/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@
from pandas.core.indexes.datetimes import DatetimeIndex
from pandas.core.indexes.interval import IntervalIndex
from pandas.core.indexes.multi import MultiIndex
from pandas.core.indexes.numeric import (
Float64Index,
Int64Index,
NumericIndex,
UInt64Index,
)
from pandas.core.indexes.numeric import NumericIndex
from pandas.core.indexes.period import PeriodIndex
from pandas.core.indexes.range import RangeIndex
from pandas.core.indexes.timedeltas import TimedeltaIndex
Expand All @@ -52,12 +47,9 @@
"Index",
"MultiIndex",
"NumericIndex",
"Float64Index",
"Int64Index",
"CategoricalIndex",
"IntervalIndex",
"RangeIndex",
"UInt64Index",
"InvalidIndexError",
"TimedeltaIndex",
"PeriodIndex",
Expand Down
13 changes: 5 additions & 8 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,6 @@ class Index(IndexOpsMixin, PandasObject):
TimedeltaIndex : Index of timedelta64 data.
PeriodIndex : Index of Period data.
NumericIndex : Index of numpy int/uint/float data.
Int64Index : Index of purely int64 labels (deprecated).
UInt64Index : Index of purely uint64 labels (deprecated).
Float64Index : Index of purely float64 labels (deprecated).
Notes
-----
Expand Down Expand Up @@ -498,7 +495,7 @@ def __new__(

klass = cls._dtype_to_subclass(arr.dtype)

# _ensure_array _may_ be unnecessary once Int64Index etc are gone
# _ensure_array _may_ be unnecessary once NumericIndex etc are gone
arr = klass._ensure_array(arr, arr.dtype, copy=False)
return klass._simple_new(arr, name)

Expand Down Expand Up @@ -1026,7 +1023,7 @@ def take(
taken = values.take(
indices, allow_fill=allow_fill, fill_value=self._na_value
)
# _constructor so RangeIndex->Int64Index
# _constructor so RangeIndex-> Index with an int64 dtype
return self._constructor._simple_new(taken, name=self.name)

@final
Expand Down Expand Up @@ -1097,7 +1094,7 @@ def repeat(self, repeats, axis=None):
nv.validate_repeat((), {"axis": axis})
res_values = self._values.repeat(repeats)

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

# --------------------------------------------------------------------
Expand Down Expand Up @@ -6228,7 +6225,7 @@ def _maybe_cast_slice_bound(self, label, side: str_t):
"""

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

Expand Down Expand Up @@ -6442,7 +6439,7 @@ def delete(self: _IndexT, loc) -> _IndexT:
else:
res_values = values.delete(loc)

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

def insert(self, loc: int, item) -> Index:
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
if TYPE_CHECKING:
from pandas.core.api import (
DataFrame,
Float64Index,
NumericIndex,
PeriodIndex,
)

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

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

arr = self._data.to_julian_date()
return Float64Index._simple_new(arr, name=self.name)
return NumericIndex._simple_new(arr, name=self.name)

@doc(DatetimeArray.isocalendar)
def isocalendar(self) -> DataFrame:
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def _maybe_convert_i8(self, key):
-------
scalar or list-like
The original key if no conversion occurred, int if converted scalar,
Int64Index if converted list-like.
Index with an int64 dtype if converted list-like.
"""
if is_list_like(key):
key = ensure_index(key)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ def get_level_values(self, level):
level_1 int64
dtype: object
>>> pd.MultiIndex.from_arrays([[1, None, 2], [3, 4, 5]]).get_level_values(0)
Float64Index([1.0, nan, 2.0], dtype='float64')
NumericIndex([1.0, nan, 2.0], dtype='float64')
"""
level = self._get_level_number(level)
values = self._get_level_values(level)
Expand Down
Loading

0 comments on commit f298778

Please sign in to comment.