Skip to content

Commit cc238b9

Browse files
authored
EA: tighten TimedeltaArray._from_sequence signature (#36731)
1 parent b083ef3 commit cc238b9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pandas/core/arrays/timedeltas.py

+13
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,19 @@ def _simple_new(
214214

215215
@classmethod
216216
def _from_sequence(
217+
cls, data, dtype=TD64NS_DTYPE, copy: bool = False
218+
) -> "TimedeltaArray":
219+
if dtype:
220+
_validate_td64_dtype(dtype)
221+
222+
data, inferred_freq = sequence_to_td64ns(data, copy=copy, unit=None)
223+
freq, _ = dtl.validate_inferred_freq(None, inferred_freq, False)
224+
225+
result = cls._simple_new(data, freq=freq)
226+
return result
227+
228+
@classmethod
229+
def _from_sequence_not_strict(
217230
cls,
218231
data,
219232
dtype=TD64NS_DTYPE,

pandas/core/indexes/timedeltas.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def __new__(
153153

154154
# - Cases checked above all return/raise before reaching here - #
155155

156-
tdarr = TimedeltaArray._from_sequence(
156+
tdarr = TimedeltaArray._from_sequence_not_strict(
157157
data, freq=freq, unit=unit, dtype=dtype, copy=copy
158158
)
159159
return cls._simple_new(tdarr, name=name)

0 commit comments

Comments
 (0)