diff --git a/pandas-stubs/_libs/tslibs/timedeltas.pyi b/pandas-stubs/_libs/tslibs/timedeltas.pyi index b0f9bdf0..081f11e9 100644 --- a/pandas-stubs/_libs/tslibs/timedeltas.pyi +++ b/pandas-stubs/_libs/tslibs/timedeltas.pyi @@ -102,7 +102,7 @@ class Timedelta(timedelta): value: int def __new__( cls, - value: str | int | Timedelta | timedelta | np.timedelta64 = ..., + value: str | float | Timedelta | timedelta | np.timedelta64 = ..., unit: TimeDeltaUnitChoices = ..., *, days: float | np.integer | np.floating = ..., diff --git a/tests/test_timefuncs.py b/tests/test_timefuncs.py index 9722c314..c38d832a 100644 --- a/tests/test_timefuncs.py +++ b/tests/test_timefuncs.py @@ -149,6 +149,11 @@ def test_timedelta_series_arithmetic() -> None: r4: pd.TimedeltaIndex = tds1 / 10.2 +def test_timedelta_float_value() -> None: + # GH 1015 + check(assert_type(pd.Timedelta(1.5, "h"), pd.Timedelta), pd.Timedelta) + + def test_timedelta_series_string() -> None: seq_list = ["1 day"] check(assert_type(pd.to_timedelta(seq_list), pd.TimedeltaIndex), pd.TimedeltaIndex)