Skip to content
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