Skip to content

Commit 425bdb3

Browse files
jorisvandenbosscheWillAyd
authored andcommittedAug 13, 2024
String dtype: use 'str' string alias and representation for NaN-variant of the dtype (#59388)
1 parent 310aa13 commit 425bdb3

File tree

79 files changed

+306
-192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+306
-192
lines changed
 

‎pandas/_testing/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import numpy as np
1616

17+
from pandas._config import using_string_dtype
1718
from pandas._config.localization import (
1819
can_set_locale,
1920
get_locales,
@@ -110,7 +111,10 @@
110111
ALL_FLOAT_DTYPES: list[Dtype] = [*FLOAT_NUMPY_DTYPES, *FLOAT_EA_DTYPES]
111112

112113
COMPLEX_DTYPES: list[Dtype] = [complex, "complex64", "complex128"]
113-
STRING_DTYPES: list[Dtype] = [str, "str", "U"]
114+
if using_string_dtype():
115+
STRING_DTYPES: list[Dtype] = [str, "U"]
116+
else:
117+
STRING_DTYPES: list[Dtype] = [str, "str", "U"] # type: ignore[no-redef]
114118

115119
DATETIME64_DTYPES: list[Dtype] = ["datetime64[ns]", "M8[ns]"]
116120
TIMEDELTA64_DTYPES: list[Dtype] = ["timedelta64[ns]", "m8[ns]"]

‎pandas/core/arrays/arrow/array.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,10 @@ def __getitem__(self, item: PositionalIndexer):
570570
if isinstance(item, np.ndarray):
571571
if not len(item):
572572
# Removable once we migrate StringDtype[pyarrow] to ArrowDtype[string]
573-
if self._dtype.name == "string" and self._dtype.storage == "pyarrow":
573+
if (
574+
isinstance(self._dtype, StringDtype)
575+
and self._dtype.storage == "pyarrow"
576+
):
574577
# TODO(infer_string) should this be large_string?
575578
pa_dtype = pa.string()
576579
else:

0 commit comments

Comments
 (0)