Skip to content
Merged
27 changes: 25 additions & 2 deletions pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -791,9 +791,32 @@ cdef class _Timedelta(timedelta):
@property
def nanoseconds(self):
"""
Number of nanoseconds (>= 0 and less than 1 microsecond).
Return the number of nanoseconds (n), where 0 <= n < 1 microsecond.

Returns
-------
int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be on the same line with a colon? @TomAugspurger @jorisvandenbossche

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine as is. It's typically

name : type
    Explanation

but when the name is obvious (it'd just be nanoseconds here), it can be omitted.

Number of nanoseconds.

See Also
--------
Timedelta.components : Return all attributes with assigned values
(i.e. days, hours, minutes, seconds, milliseconds, microseconds,
nanoseconds).

Examples
--------
**Using string input**

>>> td = pd.Timedelta('1 days 2 min 3 us 42 ns')
>>> td.nanoseconds
42

**Using integer input**

.components will return the shown components
>>> td = pd.Timedelta(42, unit='ns')
>>> td.nanoseconds
42
"""
self._ensure_components()
return self._ns
Expand Down