Skip to content

Commit 0366ebf

Browse files
committed
Merge pull request pandas-dev#6412 from cpcloud/replace-bool-doc-fix
DOC: use ipython in bool replace doc warning
2 parents 17f84af + 342423f commit 0366ebf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

doc/source/missing_data.rst

+5-3
Original file line numberDiff line numberDiff line change
@@ -602,17 +602,19 @@ You can also operate on the DataFrame in place
602602
argument to ``replace`` (``to_replace``) must match the type of the value
603603
being replaced type. For example,
604604

605-
.. code-block::
605+
.. code-block:: python
606606
607607
s = Series([True, False, True])
608-
s.replace({'a string': 'new value', True: False})
608+
s.replace({'a string': 'new value', True: False}) # raises
609+
610+
TypeError: Cannot compare types 'ndarray(dtype=bool)' and 'str'
609611
610612
will raise a ``TypeError`` because one of the ``dict`` keys is not of the
611613
correct type for replacement.
612614

613615
However, when replacing a *single* object such as,
614616

615-
.. code-block::
617+
.. ipython:: python
616618
617619
s = Series([True, False, True])
618620
s.replace('a string', 'another string')

0 commit comments

Comments
 (0)