@@ -288,6 +288,11 @@ class Index(IndexOpsMixin, PandasObject):
288288
289289 The basic object storing axis labels for all pandas objects.
290290
291+ .. versionchanged:: 2.0.0
292+
293+ Index can hold all numpy numeric dtypes (except float16). Previously only
294+ int64/uint64/float64 dtypes were accepted.
295+
291296 Parameters
292297 ----------
293298 data : array-like (1-dimensional)
@@ -315,7 +320,8 @@ class Index(IndexOpsMixin, PandasObject):
315320
316321 Notes
317322 -----
318- An Index instance can **only** contain hashable objects
323+ An Index instance can **only** contain hashable objects.
324+ An Index instance *can not* hold numpy float16 dtype.
319325
320326 Examples
321327 --------
@@ -324,6 +330,9 @@ class Index(IndexOpsMixin, PandasObject):
324330
325331 >>> pd.Index(list('abc'))
326332 Index(['a', 'b', 'c'], dtype='object')
333+
334+ >>> pd.Index([1, 2, 3], dtype="uint8")
335+ NumericIndex([1, 2, 3], dtype='uint8')
327336 """
328337
329338 # To hand over control to subclasses
@@ -400,7 +409,10 @@ def _outer_indexer(
400409 _no_setting_name : bool = False
401410 _comparables : list [str ] = ["name" ]
402411 _attributes : list [str ] = ["name" ]
403- _can_hold_strings : bool = True
412+
413+ @cache_readonly
414+ def _can_hold_strings (self ) -> bool :
415+ return not is_numeric_dtype (self )
404416
405417 _engine_types : dict [np .dtype | ExtensionDtype , type [libindex .IndexEngine ]] = {
406418 np .dtype (np .int8 ): libindex .Int8Engine ,
0 commit comments