Skip to content

Commit f251aa6

Browse files
committed
catch replace list with scalar case
1 parent be6ad72 commit f251aa6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pandas/core/internals/blocks.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -777,12 +777,11 @@ def copy(self, deep=True, mgr=None):
777777

778778
def replace(self, to_replace, value, inplace=False, filter=None,
779779
regex=False, convert=True, mgr=None):
780-
""" replace the to_replace value with value, possible to create new
780+
"""
781+
replace the to_replace value with value, possible to create new
781782
blocks here this is just a call to putmask. regex is not used here.
782-
It is used in ObjectBlocks. It is here for API
783-
compatibility.
783+
It is used in ObjectBlocks. It is here for API compatibility.
784784
"""
785-
786785
inplace = validate_bool_kwarg(inplace, 'inplace')
787786
original_to_replace = to_replace
788787

@@ -2459,6 +2458,9 @@ def replace(self, to_replace, value, inplace=False, filter=None,
24592458
blocks = result_blocks
24602459
return result_blocks
24612460

2461+
elif to_rep_is_list and not value_is_list:
2462+
to_replace = np.array(to_replace)[np.newaxis, :]
2463+
24622464
return self._replace_single(to_replace, value, inplace=inplace,
24632465
filter=filter, convert=convert,
24642466
regex=regex, mgr=mgr)

0 commit comments

Comments
 (0)