@@ -320,7 +320,7 @@ class Index(IndexOpsMixin, PandasObject):
320
320
Examples
321
321
--------
322
322
>>> pd.Index([1, 2, 3])
323
- NumericIndex ([1, 2, 3], dtype='int64')
323
+ Index ([1, 2, 3], dtype='int64')
324
324
325
325
>>> pd.Index(list('abc'))
326
326
Index(['a', 'b', 'c'], dtype='object')
@@ -1194,6 +1194,10 @@ def __repr__(self) -> str_t:
1194
1194
Return a string representation for this object.
1195
1195
"""
1196
1196
klass_name = type (self ).__name__
1197
+ from pandas .core .indexes .numeric import NumericIndex
1198
+
1199
+ if type (self ) is NumericIndex :
1200
+ klass_name = "Index"
1197
1201
data = self ._format_data ()
1198
1202
attrs = self ._format_attrs ()
1199
1203
space = self ._format_space ()
@@ -1717,9 +1721,9 @@ def set_names(
1717
1721
--------
1718
1722
>>> idx = pd.Index([1, 2, 3, 4])
1719
1723
>>> idx
1720
- NumericIndex ([1, 2, 3, 4], dtype='int64')
1724
+ Index ([1, 2, 3, 4], dtype='int64')
1721
1725
>>> idx.set_names('quarter')
1722
- NumericIndex ([1, 2, 3, 4], dtype='int64', name='quarter')
1726
+ Index ([1, 2, 3, 4], dtype='int64', name='quarter')
1723
1727
1724
1728
>>> idx = pd.MultiIndex.from_product([['python', 'cobra'],
1725
1729
... [2018, 2019]])
@@ -2005,7 +2009,7 @@ def droplevel(self, level: IndexLabel = 0):
2005
2009
names=['x', 'y'])
2006
2010
2007
2011
>>> mi.droplevel(['x', 'y'])
2008
- NumericIndex ([5, 6], dtype='int64', name='z')
2012
+ Index ([5, 6], dtype='int64', name='z')
2009
2013
"""
2010
2014
if not isinstance (level , (tuple , list )):
2011
2015
level = [level ]
@@ -2714,7 +2718,7 @@ def isna(self) -> npt.NDArray[np.bool_]:
2714
2718
2715
2719
>>> idx = pd.Index([5.2, 6.0, np.NaN])
2716
2720
>>> idx
2717
- NumericIndex ([5.2, 6.0, nan], dtype='float64')
2721
+ Index ([5.2, 6.0, nan], dtype='float64')
2718
2722
>>> idx.isna()
2719
2723
array([False, False, True])
2720
2724
@@ -2771,7 +2775,7 @@ def notna(self) -> npt.NDArray[np.bool_]:
2771
2775
2772
2776
>>> idx = pd.Index([5.2, 6.0, np.NaN])
2773
2777
>>> idx
2774
- NumericIndex ([5.2, 6.0, nan], dtype='float64')
2778
+ Index ([5.2, 6.0, nan], dtype='float64')
2775
2779
>>> idx.notna()
2776
2780
array([ True, True, False])
2777
2781
@@ -3082,7 +3086,7 @@ def union(self, other, sort=None):
3082
3086
>>> idx1 = pd.Index([1, 2, 3, 4])
3083
3087
>>> idx2 = pd.Index([3, 4, 5, 6])
3084
3088
>>> idx1.union(idx2)
3085
- NumericIndex ([1, 2, 3, 4, 5, 6], dtype='int64')
3089
+ Index ([1, 2, 3, 4, 5, 6], dtype='int64')
3086
3090
3087
3091
Union mismatched dtypes
3088
3092
@@ -3274,7 +3278,7 @@ def intersection(self, other, sort: bool = False):
3274
3278
>>> idx1 = pd.Index([1, 2, 3, 4])
3275
3279
>>> idx2 = pd.Index([3, 4, 5, 6])
3276
3280
>>> idx1.intersection(idx2)
3277
- NumericIndex ([3, 4], dtype='int64')
3281
+ Index ([3, 4], dtype='int64')
3278
3282
"""
3279
3283
self ._validate_sort_keyword (sort )
3280
3284
self ._assert_can_do_setop (other )
@@ -3421,9 +3425,9 @@ def difference(self, other, sort=None):
3421
3425
>>> idx1 = pd.Index([2, 1, 3, 4])
3422
3426
>>> idx2 = pd.Index([3, 4, 5, 6])
3423
3427
>>> idx1.difference(idx2)
3424
- NumericIndex ([1, 2], dtype='int64')
3428
+ Index ([1, 2], dtype='int64')
3425
3429
>>> idx1.difference(idx2, sort=False)
3426
- NumericIndex ([2, 1], dtype='int64')
3430
+ Index ([2, 1], dtype='int64')
3427
3431
"""
3428
3432
self ._validate_sort_keyword (sort )
3429
3433
self ._assert_can_do_setop (other )
@@ -3504,7 +3508,7 @@ def symmetric_difference(self, other, result_name=None, sort=None):
3504
3508
>>> idx1 = pd.Index([1, 2, 3, 4])
3505
3509
>>> idx2 = pd.Index([2, 3, 4, 5])
3506
3510
>>> idx1.symmetric_difference(idx2)
3507
- NumericIndex ([1, 5], dtype='int64')
3511
+ Index ([1, 5], dtype='int64')
3508
3512
"""
3509
3513
self ._validate_sort_keyword (sort )
3510
3514
self ._assert_can_do_setop (other )
@@ -5069,7 +5073,7 @@ def __contains__(self, key: Any) -> bool:
5069
5073
--------
5070
5074
>>> idx = pd.Index([1, 2, 3, 4])
5071
5075
>>> idx
5072
- NumericIndex ([1, 2, 3, 4], dtype='int64')
5076
+ Index ([1, 2, 3, 4], dtype='int64')
5073
5077
5074
5078
>>> 2 in idx
5075
5079
True
@@ -5268,7 +5272,7 @@ def equals(self, other: Any) -> bool:
5268
5272
--------
5269
5273
>>> idx1 = pd.Index([1, 2, 3])
5270
5274
>>> idx1
5271
- NumericIndex ([1, 2, 3], dtype='int64')
5275
+ Index ([1, 2, 3], dtype='int64')
5272
5276
>>> idx1.equals(pd.Index([1, 2, 3]))
5273
5277
True
5274
5278
@@ -5285,21 +5289,21 @@ def equals(self, other: Any) -> bool:
5285
5289
5286
5290
>>> ascending_idx = pd.Index([1, 2, 3])
5287
5291
>>> ascending_idx
5288
- NumericIndex ([1, 2, 3], dtype='int64')
5292
+ Index ([1, 2, 3], dtype='int64')
5289
5293
>>> descending_idx = pd.Index([3, 2, 1])
5290
5294
>>> descending_idx
5291
- NumericIndex ([3, 2, 1], dtype='int64')
5295
+ Index ([3, 2, 1], dtype='int64')
5292
5296
>>> ascending_idx.equals(descending_idx)
5293
5297
False
5294
5298
5295
5299
The dtype is *not* compared
5296
5300
5297
5301
>>> int64_idx = pd.Index([1, 2, 3], dtype='int64')
5298
5302
>>> int64_idx
5299
- NumericIndex ([1, 2, 3], dtype='int64')
5303
+ Index ([1, 2, 3], dtype='int64')
5300
5304
>>> uint64_idx = pd.Index([1, 2, 3], dtype='uint64')
5301
5305
>>> uint64_idx
5302
- NumericIndex ([1, 2, 3], dtype='uint64')
5306
+ Index ([1, 2, 3], dtype='uint64')
5303
5307
>>> int64_idx.equals(uint64_idx)
5304
5308
True
5305
5309
"""
@@ -5522,18 +5526,18 @@ def sort_values(
5522
5526
--------
5523
5527
>>> idx = pd.Index([10, 100, 1, 1000])
5524
5528
>>> idx
5525
- NumericIndex ([10, 100, 1, 1000], dtype='int64')
5529
+ Index ([10, 100, 1, 1000], dtype='int64')
5526
5530
5527
5531
Sort values in ascending order (default behavior).
5528
5532
5529
5533
>>> idx.sort_values()
5530
- NumericIndex ([1, 10, 100, 1000], dtype='int64')
5534
+ Index ([1, 10, 100, 1000], dtype='int64')
5531
5535
5532
5536
Sort values in descending order, and also get the indices `idx` was
5533
5537
sorted by.
5534
5538
5535
5539
>>> idx.sort_values(ascending=False, return_indexer=True)
5536
- (NumericIndex ([1000, 100, 10, 1], dtype='int64'), array([3, 1, 0, 2]))
5540
+ (Index ([1000, 100, 10, 1], dtype='int64'), array([3, 1, 0, 2]))
5537
5541
"""
5538
5542
idx = ensure_key_mapped (self , key )
5539
5543
@@ -6180,7 +6184,7 @@ def isin(self, values, level=None) -> npt.NDArray[np.bool_]:
6180
6184
--------
6181
6185
>>> idx = pd.Index([1,2,3])
6182
6186
>>> idx
6183
- NumericIndex ([1, 2, 3], dtype='int64')
6187
+ Index ([1, 2, 3], dtype='int64')
6184
6188
6185
6189
Check whether each index value in a list of values.
6186
6190
@@ -6977,7 +6981,7 @@ def ensure_index_from_sequences(sequences, names=None) -> Index:
6977
6981
Examples
6978
6982
--------
6979
6983
>>> ensure_index_from_sequences([[1, 2, 3]], names=["name"])
6980
- NumericIndex ([1, 2, 3], dtype='int64', name='name')
6984
+ Index ([1, 2, 3], dtype='int64', name='name')
6981
6985
6982
6986
>>> ensure_index_from_sequences([["a", "a"], ["a", "b"]], names=["L1", "L2"])
6983
6987
MultiIndex([('a', 'a'),
0 commit comments