Skip to content

Commit 9d30ee4

Browse files
committed
fix dtype issues
1 parent c1906e2 commit 9d30ee4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pandas/core/dtypes/cast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,7 @@ def construct_1d_ndarray_preserving_na(
16181618
array(['1.0', '2.0', None], dtype=object)
16191619
"""
16201620

1621-
if is_string_dtype(dtype):
1621+
if dtype is not None and dtype.kind == "U":
16221622
subarr = lib.ensure_string_array(values, convert_na_value=False, copy=copy)
16231623
else:
16241624
subarr = np.array(values, dtype=dtype, copy=copy)

pandas/core/internals/construction.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def init_ndarray(values, index, columns, dtype: Optional[DtypeObj], copy: bool):
190190
# the dtypes will be coerced to a single dtype
191191
values = _prep_ndarray(values, copy=copy)
192192

193-
if not is_dtype_equal(values.dtype, dtype):
193+
if dtype is not None and not is_dtype_equal(values.dtype, dtype):
194194
try:
195195
values = construct_1d_ndarray_preserving_na(
196196
values.ravel(), dtype=dtype, copy=False

0 commit comments

Comments
 (0)