Skip to content

Commit 36c3a60

Browse files
BUG: fix BooleanArray.astype('string') (GH34110) (#34509)
1 parent 6eb34f1 commit 36c3a60

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pandas/core/arrays/boolean.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,15 @@ def astype(self, dtype, copy: bool = True) -> ArrayLike:
370370
if incompatible type with an BooleanDtype, equivalent of same_kind
371371
casting
372372
"""
373+
from pandas.core.arrays.string_ import StringDtype
374+
373375
dtype = pandas_dtype(dtype)
374376

375377
if isinstance(dtype, BooleanDtype):
376378
values, mask = coerce_to_array(self, copy=copy)
377379
return BooleanArray(values, mask, copy=False)
380+
elif isinstance(dtype, StringDtype):
381+
return dtype.construct_array_type()._from_sequence(self, copy=False)
378382

379383
if is_bool_dtype(dtype):
380384
# astype_nansafe converts np.nan to True

0 commit comments

Comments
 (0)