|
90 | 90 | ensure_platform_int,
|
91 | 91 | is_bool_dtype,
|
92 | 92 | is_categorical_dtype,
|
93 |
| - is_complex_dtype, |
94 | 93 | is_dtype_equal,
|
95 | 94 | is_ea_or_datetimelike_dtype,
|
96 | 95 | is_extension_array_dtype,
|
|
107 | 106 | is_scalar,
|
108 | 107 | is_signed_integer_dtype,
|
109 | 108 | is_string_dtype,
|
110 |
| - is_unsigned_integer_dtype, |
111 | 109 | needs_i8_conversion,
|
112 | 110 | pandas_dtype,
|
113 | 111 | validate_all_hashable,
|
|
125 | 123 | ABCDatetimeIndex,
|
126 | 124 | ABCMultiIndex,
|
127 | 125 | ABCPeriodIndex,
|
128 |
| - ABCRangeIndex, |
129 | 126 | ABCSeries,
|
130 | 127 | ABCTimedeltaIndex,
|
131 | 128 | )
|
@@ -392,11 +389,6 @@ def _outer_indexer(
|
392 | 389 | _attributes: list[str] = ["name"]
|
393 | 390 | _can_hold_strings: bool = True
|
394 | 391 |
|
395 |
| - # Whether this index is a NumericIndex, but not a Int64Index, Float64Index, |
396 |
| - # UInt64Index or RangeIndex. Needed for backwards compat. Remove this attribute and |
397 |
| - # associated code in pandas 2.0. |
398 |
| - _is_backward_compat_public_numeric_index: bool = False |
399 |
| - |
400 | 392 | @property
|
401 | 393 | def _engine_type(
|
402 | 394 | self,
|
@@ -446,13 +438,6 @@ def __new__(
|
446 | 438 | elif is_ea_or_datetimelike_dtype(data_dtype):
|
447 | 439 | pass
|
448 | 440 |
|
449 |
| - # index-like |
450 |
| - elif ( |
451 |
| - isinstance(data, Index) |
452 |
| - and data._is_backward_compat_public_numeric_index |
453 |
| - and dtype is None |
454 |
| - ): |
455 |
| - return data._constructor(data, name=name, copy=copy) |
456 | 441 | elif isinstance(data, (np.ndarray, Index, ABCSeries)):
|
457 | 442 |
|
458 | 443 | if isinstance(data, ABCMultiIndex):
|
@@ -981,34 +966,6 @@ def astype(self, dtype, copy: bool = True):
|
981 | 966 | new_values = astype_array(values, dtype=dtype, copy=copy)
|
982 | 967 |
|
983 | 968 | # pass copy=False because any copying will be done in the astype above
|
984 |
| - if not self._is_backward_compat_public_numeric_index and not isinstance( |
985 |
| - self, ABCRangeIndex |
986 |
| - ): |
987 |
| - # this block is needed so e.g. Int64Index.astype("int32") returns |
988 |
| - # Int64Index and not a NumericIndex with dtype int32. |
989 |
| - # When Int64Index etc. are removed from the code base, removed this also. |
990 |
| - if ( |
991 |
| - isinstance(dtype, np.dtype) |
992 |
| - and is_numeric_dtype(dtype) |
993 |
| - and not is_complex_dtype(dtype) |
994 |
| - ): |
995 |
| - from pandas.core.api import ( |
996 |
| - Float64Index, |
997 |
| - Int64Index, |
998 |
| - UInt64Index, |
999 |
| - ) |
1000 |
| - |
1001 |
| - klass: type[Index] |
1002 |
| - if is_signed_integer_dtype(dtype): |
1003 |
| - klass = Int64Index |
1004 |
| - elif is_unsigned_integer_dtype(dtype): |
1005 |
| - klass = UInt64Index |
1006 |
| - elif is_float_dtype(dtype): |
1007 |
| - klass = Float64Index |
1008 |
| - else: |
1009 |
| - klass = Index |
1010 |
| - return klass(new_values, name=self.name, dtype=dtype, copy=False) |
1011 |
| - |
1012 | 969 | return Index(new_values, name=self.name, dtype=new_values.dtype, copy=False)
|
1013 | 970 |
|
1014 | 971 | _index_shared_docs[
|
@@ -5089,10 +5046,6 @@ def _concat(self, to_concat: list[Index], name: Hashable) -> Index:
|
5089 | 5046 |
|
5090 | 5047 | result = concat_compat(to_concat_vals)
|
5091 | 5048 |
|
5092 |
| - is_numeric = result.dtype.kind in ["i", "u", "f"] |
5093 |
| - if self._is_backward_compat_public_numeric_index and is_numeric: |
5094 |
| - return type(self)._simple_new(result, name=name) |
5095 |
| - |
5096 | 5049 | return Index._with_infer(result, name=name)
|
5097 | 5050 |
|
5098 | 5051 | def putmask(self, mask, value) -> Index:
|
@@ -6490,12 +6443,7 @@ def insert(self, loc: int, item) -> Index:
|
6490 | 6443 | loc = loc if loc >= 0 else loc - 1
|
6491 | 6444 | new_values[loc] = item
|
6492 | 6445 |
|
6493 |
| - if self._typ == "numericindex": |
6494 |
| - # Use self._constructor instead of Index to retain NumericIndex GH#43921 |
6495 |
| - # TODO(2.0) can use Index instead of self._constructor |
6496 |
| - return self._constructor(new_values, name=self.name) |
6497 |
| - else: |
6498 |
| - return Index._with_infer(new_values, name=self.name) |
| 6446 | + return Index._with_infer(new_values, name=self.name) |
6499 | 6447 |
|
6500 | 6448 | def drop(
|
6501 | 6449 | self,
|
|
0 commit comments