File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -602,17 +602,19 @@ You can also operate on the DataFrame in place
602
602
argument to ``replace `` (``to_replace ``) must match the type of the value
603
603
being replaced type. For example,
604
604
605
- .. code-block ::
605
+ .. code-block :: python
606
606
607
607
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'
609
611
610
612
will raise a ``TypeError `` because one of the ``dict `` keys is not of the
611
613
correct type for replacement.
612
614
613
615
However, when replacing a *single * object such as,
614
616
615
- .. code-block ::
617
+ .. ipython :: python
616
618
617
619
s = Series([True , False , True ])
618
620
s.replace(' a string' , ' another string' )
You can’t perform that action at this time.
0 commit comments