diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 962e7cc86a98b..14823326dd43d 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -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 \ diff --git a/pandas/core/arrays/timedeltas.py b/pandas/core/arrays/timedeltas.py index f266ef850866d..d4c15a0650ee0 100644 --- a/pandas/core/arrays/timedeltas.py +++ b/pandas/core/arrays/timedeltas.py @@ -78,6 +78,8 @@ from pandas import DataFrame +import textwrap + def _field_accessor(name: str, alias: str, docstring: str): def f(self) -> np.ndarray: @@ -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",