Skip to content

Commit f2492e4

Browse files
committed
DOC: add small caveat section in missing_data.rst
1 parent 7dde997 commit f2492e4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

doc/source/missing_data.rst

+25
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,31 @@ You can also operate on the DataFrame in place
596596
597597
df.replace(1.5, nan, inplace=True)
598598
599+
.. warning::
600+
601+
When replacing multiple ``bool`` or ``datetime64`` objects, the first
602+
argument to ``replace`` (``to_replace``) must match the type of the value
603+
being replaced type. For example,
604+
605+
.. code-block::
606+
607+
s = Series([True, False, True])
608+
s.replace({'a string': 'new value', True: False})
609+
610+
will raise a ``TypeError`` because one of the ``dict`` keys is not of the
611+
correct type for replacement.
612+
613+
However, when replacing a *single* object such as,
614+
615+
.. code-block::
616+
617+
s = Series([True, False, True])
618+
s.replace('a string', 'another string')
619+
620+
the original ``NDFrame`` object will be returned untouched. We're working on
621+
unifying this API, but for backwards compatibility reasons we cannot break
622+
the latter behavior. See :issue:`6354` for more details.
623+
599624
Missing data casting rules and indexing
600625
---------------------------------------
601626

0 commit comments

Comments
 (0)