Skip to content

Commit 7077a08

Browse files
xhochysimonjayhawkinsjorisvandenbossche
authored
ENH: Basis for a StringDtype using Arrow (#35259)
Co-authored-by: Simon Hawkins <[email protected]> Co-authored-by: Joris Van den Bossche <[email protected]>
1 parent 8488730 commit 7077a08

File tree

7 files changed

+976
-113
lines changed

7 files changed

+976
-113
lines changed

pandas/_libs/lib.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ cpdef ndarray[object] ensure_string_array(
636636
----------
637637
arr : array-like
638638
The values to be converted to str, if needed.
639-
na_value : Any
639+
na_value : Any, default np.nan
640640
The value to use for na. For example, np.nan or pd.NA.
641641
convert_na_value : bool, default True
642642
If False, existing na values will be used unchanged in the new array.

pandas/core/arrays/base.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -471,14 +471,19 @@ def astype(self, dtype, copy=True):
471471
NumPy ndarray with 'dtype' for its dtype.
472472
"""
473473
from pandas.core.arrays.string_ import StringDtype
474+
from pandas.core.arrays.string_arrow import ArrowStringDtype
474475

475476
dtype = pandas_dtype(dtype)
476477
if is_dtype_equal(dtype, self.dtype):
477478
if not copy:
478479
return self
479480
else:
480481
return self.copy()
481-
if isinstance(dtype, StringDtype): # allow conversion to StringArrays
482+
483+
# FIXME: Really hard-code here?
484+
if isinstance(
485+
dtype, (ArrowStringDtype, StringDtype)
486+
): # allow conversion to StringArrays
482487
return dtype.construct_array_type()._from_sequence(self, copy=False)
483488

484489
return np.array(self, dtype=dtype, copy=copy)

0 commit comments

Comments
 (0)