Skip to content

Commit c005778

Browse files
update datetimelike input validation
1 parent 03d4943 commit c005778

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pandas/core/arrays/datetimelike.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@
130130
from pandas.core.arrays.integer import IntegerArray
131131
import pandas.core.common as com
132132
from pandas.core.construction import (
133-
array as pd_array,
134133
ensure_wrapped_if_datetimelike,
135134
extract_array,
135+
sanitize_array,
136136
)
137137
from pandas.core.indexers import (
138138
check_array_indexer,
@@ -667,12 +667,10 @@ def _validate_listlike(self, value, allow_object: bool = False):
667667
msg = self._validation_error_message(value, True)
668668
raise TypeError(msg) from err
669669

670-
# Do type inference if necessary up front (after unpacking
671-
# NumpyExtensionArray)
670+
# Do type inference if necessary up front
672671
# e.g. we passed PeriodIndex.values and got an ndarray of Periods
673-
value = extract_array(value, extract_numpy=True)
674-
value = pd_array(value)
675-
value = extract_array(value, extract_numpy=True)
672+
value = sanitize_array(value, index=None)
673+
value = ensure_wrapped_if_datetimelike(value)
676674

677675
if is_all_strings(value):
678676
# We got a StringArray

0 commit comments

Comments
 (0)