Skip to content

DOC: Fixing EX01 - Added examples #53374

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 2 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.Series.backfill \
pandas.Series.ffill \
pandas.Series.pad \
pandas.Series.dt.days \
pandas.Series.dt.seconds \
pandas.Series.dt.microseconds \
pandas.Series.dt.nanoseconds \
Expand Down
21 changes: 20 additions & 1 deletion pandas/core/arrays/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@

from pandas import DataFrame

import textwrap


def _field_accessor(name: str, alias: str, docstring: str):
def f(self) -> np.ndarray:
Expand Down Expand Up @@ -797,7 +799,24 @@ def to_pytimedelta(self) -> npt.NDArray[np.object_]:
"""
return ints_to_pytimedelta(self._ndarray)

days = _field_accessor("days", "days", "Number of days for each element.")
days_docstring = textwrap.dedent(
"""Number of days for each element.

Examples
--------
>>> ser = pd.Series(pd.to_timedelta([1, 2, 3], unit='d'))
>>> ser
0 1 days
1 2 days
2 3 days
dtype: timedelta64[ns]
>>> ser.dt.days
0 1
1 2
2 3
dtype: int64"""
)
days = _field_accessor("days", "days", days_docstring)
seconds = _field_accessor(
"seconds",
"seconds",
Expand Down