Skip to content

Commit 3ee23e4

Browse files
authored
Added note in docs for giving the developer the option of choosing between both parameters and kwargs. Exampled included (pandas-dev#45261)
1 parent 8e70bf1 commit 3ee23e4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pandas/_libs/tslibs/timedeltas.pyx

+19
Original file line numberDiff line numberDiff line change
@@ -1251,10 +1251,29 @@ class Timedelta(_Timedelta):
12511251
12521252
Notes
12531253
-----
1254+
The constructor may take in either both values of value and unit or
1255+
kwargs as above. Either one of them must be used during initialization
1256+
12541257
The ``.value`` attribute is always in ns.
12551258
12561259
If the precision is higher than nanoseconds, the precision of the duration is
12571260
truncated to nanoseconds.
1261+
1262+
Examples
1263+
--------
1264+
Here we initialize Timedelta object with both value and unit
1265+
1266+
>>> td = pd.Timedelta(1, "d")
1267+
>>> td
1268+
Timedelta('1 days 00:00:00')
1269+
1270+
Here we initialize the Timedelta object with kwargs
1271+
1272+
>>> td2 = pd.Timedelta(days=1)
1273+
>>> td2
1274+
Timedelta('1 days 00:00:00')
1275+
1276+
We see that either way we get the same result
12581277
"""
12591278

12601279
_req_any_kwargs_new = {"weeks", "days", "hours", "minutes", "seconds",

0 commit comments

Comments
 (0)