Skip to content

DOC: Improved the docstring of pandas.Series.dt.to_pytimedelta #20142

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
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
DOC: Improved the docstring of pandas.Series.dt.to_pytimedelta
  • Loading branch information
ijmbarr committed Mar 10, 2018
commit 18d67b607fec051c5b5c87360ddcaed329945d6f
9 changes: 8 additions & 1 deletion pandas/core/indexes/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ def to_pytimedelta(self):
"""
Return array of Timedeltas as `datetime.timedelta`.

Return an array of the Timedeltas in `datetime.timedelta` format with
Python's standard `datetime` library uses a different representation to
what pandas for differences between times. This method converts a Series
of pandas Timedeltas to `datetime.timedelta` format with
the same length as the original Series.

Returns
Expand All @@ -178,10 +180,15 @@ def to_pytimedelta(self):
3 3 days
4 4 days
dtype: timedelta64[ns]

>>> s.dt.to_pytimedelta()
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a blank line before this case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

array([datetime.timedelta(0), datetime.timedelta(1),
datetime.timedelta(2), datetime.timedelta(3),
datetime.timedelta(4)], dtype=object)

See Also
--------
datetime.timedelta
"""
return self._get_values().to_pytimedelta()

Expand Down