From ec5ffce978ba72f28b1f9c029297f4c8325f558f Mon Sep 17 00:00:00 2001 From: Dare Adewumi <42492589+Pydare@users.noreply.github.com> Date: Sat, 8 Jan 2022 16:55:35 +0100 Subject: [PATCH] =?UTF-8?q?Backport=20PR=20#45261:=20Added=20note=20in=20d?= =?UTF-8?q?ocs=20for=20giving=20the=20developer=20the=20option=20of=20choo?= =?UTF-8?q?sing=20be=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pandas/_libs/tslibs/timedeltas.pyx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 02017c5900ca0..51624dfb3e17d 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1251,10 +1251,29 @@ class Timedelta(_Timedelta): Notes ----- + The constructor may take in either both values of value and unit or + kwargs as above. Either one of them must be used during initialization + The ``.value`` attribute is always in ns. If the precision is higher than nanoseconds, the precision of the duration is truncated to nanoseconds. + + Examples + -------- + Here we initialize Timedelta object with both value and unit + + >>> td = pd.Timedelta(1, "d") + >>> td + Timedelta('1 days 00:00:00') + + Here we initialize the Timedelta object with kwargs + + >>> td2 = pd.Timedelta(days=1) + >>> td2 + Timedelta('1 days 00:00:00') + + We see that either way we get the same result """ _req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds",