From 1dc93b521f54b0259c77e8079b03c6fae791dd24 Mon Sep 17 00:00:00 2001 From: chris-b1 Date: Wed, 19 Jul 2017 04:51:47 -0500 Subject: [PATCH] DOC: infer_objects doc fixup (#17018) --- doc/source/basics.rst | 5 +++-- doc/source/whatsnew/v0.21.0.txt | 9 +++++---- pandas/core/generic.py | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/source/basics.rst b/doc/source/basics.rst index 4211b15203721..aae1fffb7a3b6 100644 --- a/doc/source/basics.rst +++ b/doc/source/basics.rst @@ -2025,11 +2025,12 @@ object conversion pandas offers various functions to try to force conversion of types from the ``object`` dtype to other types. In cases where the data is already of the correct type, but stored in an ``object`` array, the -:meth:`~DataFrame.infer_objects` and :meth:`~Series.infer_objects` can be used to soft convert +:meth:`DataFrame.infer_objects` and :meth:`Series.infer_objects` methods can be used to soft convert to the correct type. .. ipython:: python + import datetime df = pd.DataFrame([[1, 2], ['a', 'b'], [datetime.datetime(2016, 3, 2), datetime.datetime(2016, 3, 2)]]) @@ -2037,7 +2038,7 @@ to the correct type. df df.dtypes -Because the data transposed the original inference stored all columns as object, which +Because the data was transposed the original inference stored all columns as object, which ``infer_objects`` will correct. .. ipython:: python diff --git a/doc/source/whatsnew/v0.21.0.txt b/doc/source/whatsnew/v0.21.0.txt index 9a6016c82e794..e43a5f9856253 100644 --- a/doc/source/whatsnew/v0.21.0.txt +++ b/doc/source/whatsnew/v0.21.0.txt @@ -31,13 +31,13 @@ New features ``infer_objects`` type conversion ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The `:meth:`~DataFrame.infer_objects` and :meth:`~Series.infer_objects` +The :meth:`DataFrame.infer_objects` and :meth:`Series.infer_objects` methods have been added to perform dtype inference on object columns, replacing some of the functionality of the deprecated ``convert_objects`` method. See the documentation :ref:`here ` for more details. (:issue:`11221`) -This function only performs soft conversions on object columns, converting Python objects +This method only performs soft conversions on object columns, converting Python objects to native types, but not any coercive conversions. For example: .. ipython:: python @@ -46,11 +46,12 @@ to native types, but not any coercive conversions. For example: 'B': np.array([1, 2, 3], dtype='object'), 'C': ['1', '2', '3']}) df.dtypes - df.infer_objects().dtype + df.infer_objects().dtypes Note that column ``'C'`` was not converted - only scalar numeric types will be inferred to a new type. Other types of conversion should be accomplished -using :func:`to_numeric` function (or :func:`to_datetime`, :func:`to_timedelta`). +using the :func:`to_numeric` function (or :func:`to_datetime`, :func:`to_timedelta`). + .. ipython:: python df = df.infer_objects() diff --git a/pandas/core/generic.py b/pandas/core/generic.py index c95129bdaa005..48006b11993c7 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3693,7 +3693,7 @@ def infer_objects(self): columns unchanged. The inference rules are the same as during normal Series/DataFrame construction. - .. versionadded:: 0.20.0 + .. versionadded:: 0.21.0 See Also --------