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
3 changes: 0 additions & 3 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.Series.backfill \
pandas.Series.ffill \
pandas.Series.pad \
pandas.Series.dt.seconds \
pandas.Series.dt.microseconds \
pandas.Series.dt.nanoseconds \
pandas.Series.str.center \
pandas.Series.str.decode \
pandas.Series.str.encode \
Expand Down
60 changes: 57 additions & 3 deletions pandas/core/arrays/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,20 +817,74 @@ def to_pytimedelta(self) -> npt.NDArray[np.object_]:
dtype: int64"""
)
days = _field_accessor("days", "days", days_docstring)

seconds_docstring = textwrap.dedent(
"""Number of seconds (>= 0 and less than 1 day) for each element.

Examples
--------
>>> ser = pd.Series(pd.to_timedelta([1, 2, 3], unit='S'))
>>> ser
0 0 days 00:00:01
1 0 days 00:00:02
2 0 days 00:00:03
dtype: timedelta64[ns]
>>> ser.dt.seconds
0 1
1 2
2 3
dtype: int32"""
)
seconds = _field_accessor(
"seconds",
"seconds",
"Number of seconds (>= 0 and less than 1 day) for each element.",
seconds_docstring,
)

microseconds_docstring = textwrap.dedent(
"""Number of microseconds (>= 0 and less than 1 second) for each element.

Examples
--------
>>> ser = pd.Series(pd.to_timedelta([1, 2, 3], unit='U'))
>>> ser
0 0 days 00:00:00.000001
1 0 days 00:00:00.000002
2 0 days 00:00:00.000003
dtype: timedelta64[ns]
>>> ser.dt.microseconds
0 1
1 2
2 3
dtype: int32"""
)
microseconds = _field_accessor(
"microseconds",
"microseconds",
"Number of microseconds (>= 0 and less than 1 second) for each element.",
microseconds_docstring,
)

nanoseconds_docstring = textwrap.dedent(
"""Number of nanoseconds (>= 0 and less than 1 microsecond) for each element.

Examples
--------
>>> ser = pd.Series(pd.to_timedelta([1, 2, 3], unit='N'))
>>> ser
0 0 days 00:00:00.000000001
1 0 days 00:00:00.000000002
2 0 days 00:00:00.000000003
dtype: timedelta64[ns]
>>> ser.dt.nanoseconds
0 1
1 2
2 3
dtype: int32"""
)
nanoseconds = _field_accessor(
"nanoseconds",
"nanoseconds",
"Number of nanoseconds (>= 0 and less than 1 microsecond) for each element.",
nanoseconds_docstring,
)

@property
Expand Down