diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 4e1ea07907cdb..2deaaae85e56b 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -7026,6 +7026,23 @@ def infer_objects(self, copy: bool = True) -> Index: ---------- copy : bool, default True Whether to make a copy in cases where no inference occurs. + + Returns + ------- + Index + An Index with a new dtype if the dtype was inferred + or a shallow copy if the dtype could not be inferred. + + See Also + -------- + Index.inferred_type: Return a string of the type inferred from the values. + + Examples + -------- + >>> pd.Index(["a", 1]).infer_objects() + Index(['a', '1'], dtype='object') + >>> pd.Index([1, 2], dtype="object").infer_objects() + Index([1, 2], dtype='int64') """ if self._is_multi: raise NotImplementedError(