Skip to content

Commit 8f18148

Browse files
support numpy 2.0 string
1 parent 641a25a commit 8f18148

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pandas/core/arrays/string_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def _get_common_dtype(self, dtypes: list[DtypeObj]) -> DtypeObj | None:
292292
if isinstance(dtype, StringDtype):
293293
storages.add(dtype.storage)
294294
na_values.add(dtype.na_value)
295-
elif isinstance(dtype, np.dtype) and dtype.kind == "U":
295+
elif isinstance(dtype, np.dtype) and dtype.kind in ("U", "T"):
296296
continue
297297
else:
298298
return None

pandas/tests/arrays/string_/test_concat.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import pandas as pd
99
import pandas._testing as tm
10+
from pandas.util.version import Version
1011

1112

1213
@pytest.mark.parametrize(
@@ -66,3 +67,7 @@ def test_concat_with_numpy(string_dtype_arguments):
6667
# with any other numpy dtype -> object
6768
assert find_common_type([dtype, np.dtype("S")]) == np.dtype("object")
6869
assert find_common_type([dtype, np.dtype("int64")]) == np.dtype("object")
70+
71+
if Version(np.__version__) >= Version("2"):
72+
assert find_common_type([dtype, np.dtypes.StringDtype()]) == dtype
73+
assert find_common_type([np.dtypes.StringDtype(), dtype]) == dtype

0 commit comments

Comments
 (0)