Skip to content

Commit 9a54182

Browse files
prevent unit=None from being passed to array_to_datetime_with_tz
1 parent b04455f commit 9a54182

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pandas/core/arrays/datetimes.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -2182,7 +2182,8 @@ def _sequence_to_dt64(
21822182
Returns
21832183
-------
21842184
result : numpy.ndarray
2185-
The sequence converted to a numpy array with dtype ``datetime64[ns]``.
2185+
The sequence converted to a numpy array with dtype ``datetime64[unit]``.
2186+
Where `unit` is ns unless specified otherwise.
21862187
tz : tzinfo or None
21872188
Either the user-provided tzinfo or one inferred from the data.
21882189
inferred_freq : Tick or None
@@ -2205,9 +2206,9 @@ def _sequence_to_dt64(
22052206
data, copy = maybe_convert_dtype(data, copy, tz=tz)
22062207
data_dtype = getattr(data, "dtype", None)
22072208

2208-
out_dtype = DT64NS_DTYPE
2209-
if out_unit is not None:
2210-
out_dtype = np.dtype(f"M8[{out_unit}]")
2209+
if out_unit is None:
2210+
out_unit = "ns"
2211+
out_dtype = np.dtype(f"M8[{out_unit}]")
22112212

22122213
if data_dtype == object or is_string_dtype(data_dtype):
22132214
# TODO: We do not have tests specific to string-dtypes,

0 commit comments

Comments
 (0)