Skip to content

Commit f2f4d12

Browse files
authored
add/timedeltas-seconds-documentation (#49584)
* add/timedeltas-seconds-documentation * Fix line lenght * fixing whitespace * fixing whitespace * fixing line lenght * Adding suggestions * Fixing single line error
1 parent b7ea7c6 commit f2f4d12

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

pandas/_libs/tslibs/timedeltas.pyx

+28
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,34 @@ cdef class _Timedelta(timedelta):
10351035

10361036
@property
10371037
def seconds(self) -> int: # TODO(cython3): make cdef property
1038+
"""
1039+
Return the total hours, minutes, and seconds of the timedelta as seconds.
1040+
1041+
Timedelta.seconds = hours * 3600 + minutes * 60 + seconds.
1042+
1043+
Returns
1044+
-------
1045+
int
1046+
Number of seconds.
1047+
1048+
See Also
1049+
--------
1050+
Timedelta.components : Return all attributes with assigned values
1051+
(i.e. days, hours, minutes, seconds, milliseconds, microseconds,
1052+
nanoseconds).
1053+
1054+
Examples
1055+
--------
1056+
**Using string input**
1057+
>>> td = pd.Timedelta('1 days 2 min 3 us 42 ns')
1058+
>>> td.seconds
1059+
120
1060+
1061+
**Using integer input**
1062+
>>> td = pd.Timedelta(42, unit='s')
1063+
>>> td.seconds
1064+
42
1065+
"""
10381066
# NB: using the python C-API PyDateTime_DELTA_GET_SECONDS will fail
10391067
# (or be incorrect)
10401068
self._ensure_components()

0 commit comments

Comments
 (0)