diff --git a/pandas-stubs/core/tools/timedeltas.pyi b/pandas-stubs/core/tools/timedeltas.pyi index aa2c34ac..38ed0c07 100644 --- a/pandas-stubs/core/tools/timedeltas.pyi +++ b/pandas-stubs/core/tools/timedeltas.pyi @@ -14,6 +14,7 @@ from pandas._libs.tslibs.timedeltas import TimeDeltaUnitChoices from pandas._typing import ( ArrayLike, RaiseCoerce, + SequenceNotStr, ) @overload @@ -31,8 +32,8 @@ def to_timedelta( @overload def to_timedelta( arg: ( - Sequence[float | timedelta] - | list[str | float | timedelta] + SequenceNotStr + | Sequence[float | timedelta] | tuple[str | float | timedelta, ...] | range | ArrayLike diff --git a/tests/test_timefuncs.py b/tests/test_timefuncs.py index e3dcb9a8..a61bb92c 100644 --- a/tests/test_timefuncs.py +++ b/tests/test_timefuncs.py @@ -140,6 +140,11 @@ def test_timedelta_series_arithmetic() -> None: r4: pd.TimedeltaIndex = tds1 / 10.2 +def test_timedelta_series_string() -> None: + seq_list = ["1 day"] + check(assert_type(pd.to_timedelta(seq_list), pd.TimedeltaIndex), pd.TimedeltaIndex) + + def test_timestamp_timedelta_series_arithmetic() -> None: ts1 = pd.to_datetime(pd.Series(["2022-03-05", "2022-03-06"])) assert isinstance(ts1.iloc[0], pd.Timestamp)