pandas.Index.infer_objects — pandas 3.0.0rc0+34.g04a554c9f1 documentation (original) (raw)
- API reference
- Index objects
- pandas.Index.infer_objects
final Index.infer_objects(copy=True)[source]#
If we have an object dtype, try to infer a non-object dtype.
Parameters:
copybool, 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.
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')