Skip to content

Commit 9213cd5

Browse files
DeaMariaLeontopper-123
authored andcommitted
DOC: Fixing EX01 - Added examples (pandas-dev#53374)
Trying example pd.Series.dt.days
1 parent 81b07d0 commit 9213cd5

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

ci/code_checks.sh

-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
8383
pandas.Series.backfill \
8484
pandas.Series.ffill \
8585
pandas.Series.pad \
86-
pandas.Series.dt.days \
8786
pandas.Series.dt.seconds \
8887
pandas.Series.dt.microseconds \
8988
pandas.Series.dt.nanoseconds \

pandas/core/arrays/timedeltas.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878

7979
from pandas import DataFrame
8080

81+
import textwrap
82+
8183

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

800-
days = _field_accessor("days", "days", "Number of days for each element.")
802+
days_docstring = textwrap.dedent(
803+
"""Number of days for each element.
804+
805+
Examples
806+
--------
807+
>>> ser = pd.Series(pd.to_timedelta([1, 2, 3], unit='d'))
808+
>>> ser
809+
0 1 days
810+
1 2 days
811+
2 3 days
812+
dtype: timedelta64[ns]
813+
>>> ser.dt.days
814+
0 1
815+
1 2
816+
2 3
817+
dtype: int64"""
818+
)
819+
days = _field_accessor("days", "days", days_docstring)
801820
seconds = _field_accessor(
802821
"seconds",
803822
"seconds",

0 commit comments

Comments
 (0)