Skip to content

Commit 12727f0

Browse files
committed
Try to process arrow dtype before any dtype modification
1 parent cc092e3 commit 12727f0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pandas/core/construction.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -554,20 +554,20 @@ def sanitize_array(
554554
np.ndarray or ExtensionArray
555555
"""
556556
original_dtype = dtype
557+
if (
558+
not pa_version_under10p1
559+
and isinstance(data, (pa.ChunkedArray, pa.Array))
560+
and dtype is None
561+
):
562+
dtype = ArrowDtype(data.type)
563+
557564
if isinstance(data, ma.MaskedArray):
558565
data = sanitize_masked_array(data)
559566

560567
if isinstance(dtype, NumpyEADtype):
561568
# Avoid ending up with a NumpyExtensionArray
562569
dtype = dtype.numpy_dtype
563570

564-
elif (
565-
not pa_version_under10p1
566-
and isinstance(data, (pa.ChunkedArray, pa.Array))
567-
and dtype is None
568-
):
569-
dtype = ArrowDtype(data.type)
570-
571571
infer_object = not isinstance(data, (ABCIndex, ABCSeries))
572572

573573
# extract ndarray or ExtensionArray, ensure we have no NumpyExtensionArray

0 commit comments

Comments
 (0)