Skip to content

Commit 961b924

Browse files
BUG (string dtype): let fillna with invalid value upcast to object dtype
1 parent 73da90c commit 961b924

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pandas/core/internals/blocks.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
PeriodArray,
109109
TimedeltaArray,
110110
)
111+
from pandas.core.arrays.string_ import StringDtype
111112
from pandas.core.base import PandasObject
112113
import pandas.core.common as com
113114
from pandas.core.computation import expressions
@@ -1684,7 +1685,7 @@ def where(self, other, cond) -> list[Block]:
16841685
res_values = arr._where(cond, other).T
16851686
except (ValueError, TypeError):
16861687
if self.ndim == 1 or self.shape[0] == 1:
1687-
if isinstance(self.dtype, IntervalDtype):
1688+
if isinstance(self.dtype, (IntervalDtype, StringDtype)):
16881689
# TestSetitemFloatIntervalWithIntIntervalValues
16891690
blk = self.coerce_to_target_dtype(orig_other, raise_on_upcast=False)
16901691
return blk.where(orig_other, orig_cond)
@@ -1854,7 +1855,7 @@ def fillna(
18541855
limit: int | None = None,
18551856
inplace: bool = False,
18561857
) -> list[Block]:
1857-
if isinstance(self.dtype, IntervalDtype):
1858+
if isinstance(self.dtype, (IntervalDtype, StringDtype)):
18581859
# Block.fillna handles coercion (test_fillna_interval)
18591860
if limit is not None:
18601861
raise ValueError("limit must be None")

0 commit comments

Comments
 (0)