From 2f70a1f4d11b1deca87a23c2592ac6d16e3604d9 Mon Sep 17 00:00:00 2001 From: Phillip Cloud Date: Wed, 19 Feb 2014 09:46:56 -0500 Subject: [PATCH 1/2] DOC: use ipython in bool replace doc warning --- doc/source/missing_data.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/source/missing_data.rst b/doc/source/missing_data.rst index 8a2f647792f47..8d5af68ae6df8 100644 --- a/doc/source/missing_data.rst +++ b/doc/source/missing_data.rst @@ -602,7 +602,8 @@ You can also operate on the DataFrame in place argument to ``replace`` (``to_replace``) must match the type of the value being replaced type. For example, - .. code-block:: + .. ipython:: python + :okexcept: s = Series([True, False, True]) s.replace({'a string': 'new value', True: False}) @@ -612,7 +613,7 @@ You can also operate on the DataFrame in place However, when replacing a *single* object such as, - .. code-block:: + .. ipython:: python s = Series([True, False, True]) s.replace('a string', 'another string') From 342423f0315cfaebe20a85578ee36f463c11b30d Mon Sep 17 00:00:00 2001 From: Phillip Cloud Date: Wed, 19 Feb 2014 10:11:44 -0500 Subject: [PATCH 2/2] DOC: use code block for shorter error message --- doc/source/missing_data.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/source/missing_data.rst b/doc/source/missing_data.rst index 8d5af68ae6df8..ac5c8a4463b39 100644 --- a/doc/source/missing_data.rst +++ b/doc/source/missing_data.rst @@ -602,11 +602,12 @@ You can also operate on the DataFrame in place argument to ``replace`` (``to_replace``) must match the type of the value being replaced type. For example, - .. ipython:: python - :okexcept: + .. code-block:: python s = Series([True, False, True]) - s.replace({'a string': 'new value', True: False}) + s.replace({'a string': 'new value', True: False}) # raises + + TypeError: Cannot compare types 'ndarray(dtype=bool)' and 'str' will raise a ``TypeError`` because one of the ``dict`` keys is not of the correct type for replacement.