Skip to content

DOC: updated docstring for nanoseconds function per doc guidelines #21065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 17, 2018
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