|
106 | 106 | is_scalar,
|
107 | 107 | is_signed_integer_dtype,
|
108 | 108 | is_string_dtype,
|
109 |
| - is_unsigned_integer_dtype, |
110 | 109 | needs_i8_conversion,
|
111 | 110 | pandas_dtype,
|
112 | 111 | validate_all_hashable,
|
@@ -394,7 +393,6 @@ def _outer_indexer(
|
394 | 393 | # Whether this index is a NumericIndex, but not a Int64Index, Float64Index,
|
395 | 394 | # UInt64Index or RangeIndex. Needed for backwards compat. Remove this attribute and
|
396 | 395 | # associated code in pandas 2.0.
|
397 |
| - _is_backward_compat_public_numeric_index: bool = False |
398 | 396 |
|
399 | 397 | @property
|
400 | 398 | def _engine_type(
|
@@ -445,13 +443,6 @@ def __new__(
|
445 | 443 | elif is_ea_or_datetimelike_dtype(data_dtype):
|
446 | 444 | pass
|
447 | 445 |
|
448 |
| - # index-like |
449 |
| - elif ( |
450 |
| - isinstance(data, Index) |
451 |
| - and data._is_backward_compat_public_numeric_index |
452 |
| - and dtype is None |
453 |
| - ): |
454 |
| - return data._constructor(data, name=name, copy=copy) |
455 | 446 | elif isinstance(data, (np.ndarray, Index, ABCSeries)):
|
456 | 447 |
|
457 | 448 | if isinstance(data, ABCMultiIndex):
|
@@ -980,34 +971,6 @@ def astype(self, dtype, copy: bool = True):
|
980 | 971 | new_values = astype_array(values, dtype=dtype, copy=copy)
|
981 | 972 |
|
982 | 973 | # pass copy=False because any copying will be done in the astype above
|
983 |
| - if not self._is_backward_compat_public_numeric_index and not isinstance( |
984 |
| - self, ABCRangeIndex |
985 |
| - ): |
986 |
| - # this block is needed so e.g. Int64Index.astype("int32") returns |
987 |
| - # Int64Index and not a NumericIndex with dtype int32. |
988 |
| - # When Int64Index etc. are removed from the code base, removed this also. |
989 |
| - if ( |
990 |
| - isinstance(dtype, np.dtype) |
991 |
| - and is_numeric_dtype(dtype) |
992 |
| - and not is_complex_dtype(dtype) |
993 |
| - ): |
994 |
| - from pandas.core.api import ( |
995 |
| - Float64Index, |
996 |
| - Int64Index, |
997 |
| - UInt64Index, |
998 |
| - ) |
999 |
| - |
1000 |
| - klass: type[Index] |
1001 |
| - if is_signed_integer_dtype(dtype): |
1002 |
| - klass = Int64Index |
1003 |
| - elif is_unsigned_integer_dtype(dtype): |
1004 |
| - klass = UInt64Index |
1005 |
| - elif is_float_dtype(dtype): |
1006 |
| - klass = Float64Index |
1007 |
| - else: |
1008 |
| - klass = Index |
1009 |
| - return klass(new_values, name=self.name, dtype=dtype, copy=False) |
1010 |
| - |
1011 | 974 | return Index(new_values, name=self.name, dtype=new_values.dtype, copy=False)
|
1012 | 975 |
|
1013 | 976 | _index_shared_docs[
|
@@ -5031,10 +4994,6 @@ def _concat(self, to_concat: list[Index], name: Hashable) -> Index:
|
5031 | 4994 |
|
5032 | 4995 | result = concat_compat(to_concat_vals)
|
5033 | 4996 |
|
5034 |
| - is_numeric = result.dtype.kind in ["i", "u", "f"] |
5035 |
| - if self._is_backward_compat_public_numeric_index and is_numeric: |
5036 |
| - return type(self)._simple_new(result, name=name) |
5037 |
| - |
5038 | 4997 | return Index._with_infer(result, name=name)
|
5039 | 4998 |
|
5040 | 4999 | def putmask(self, mask, value) -> Index:
|
@@ -6432,12 +6391,7 @@ def insert(self, loc: int, item) -> Index:
|
6432 | 6391 | loc = loc if loc >= 0 else loc - 1
|
6433 | 6392 | new_values[loc] = item
|
6434 | 6393 |
|
6435 |
| - if self._typ == "numericindex": |
6436 |
| - # Use self._constructor instead of Index to retain NumericIndex GH#43921 |
6437 |
| - # TODO(2.0) can use Index instead of self._constructor |
6438 |
| - return self._constructor(new_values, name=self.name) |
6439 |
| - else: |
6440 |
| - return Index._with_infer(new_values, name=self.name) |
| 6394 | + return Index._with_infer(new_values, name=self.name) |
6441 | 6395 |
|
6442 | 6396 | def drop(
|
6443 | 6397 | self,
|
|
0 commit comments