Skip to content

Commit d0fbeb4

Browse files
authored
DOC: add/fix Timedeltas docstrings (#51229)
* DOC: add/fix Timedeltas docstrings * remove function from code_checks.sh
1 parent 03088a9 commit d0fbeb4

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Diff for: ci/code_checks.sh

-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
204204
pandas.Timestamp.utctimetuple \
205205
pandas.Timestamp.weekday \
206206
pandas.arrays.DatetimeArray \
207-
pandas.Timedelta.components \
208207
pandas.Timedelta.view \
209208
pandas.Timedelta.as_unit \
210209
pandas.Timedelta.ceil \

Diff for: pandas/_libs/tslibs/timedeltas.pyx

+26
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,23 @@ cdef class _Timedelta(timedelta):
10361036

10371037
@property
10381038
def days(self) -> int: # TODO(cython3): make cdef property
1039+
"""
1040+
Returns the days of the timedelta.
1041+
1042+
Returns
1043+
-------
1044+
int
1045+
1046+
Examples
1047+
--------
1048+
>>> td = pd.Timedelta(1, "d")
1049+
>>> td.days
1050+
1
1051+
1052+
>>> td = pd.Timedelta('4 min 3 us 42 ns')
1053+
>>> td.days
1054+
0
1055+
"""
10391056
# NB: using the python C-API PyDateTime_DELTA_GET_DAYS will fail
10401057
# (or be incorrect)
10411058
self._ensure_components()
@@ -1062,11 +1079,13 @@ cdef class _Timedelta(timedelta):
10621079
Examples
10631080
--------
10641081
**Using string input**
1082+
10651083
>>> td = pd.Timedelta('1 days 2 min 3 us 42 ns')
10661084
>>> td.seconds
10671085
120
10681086
10691087
**Using integer input**
1088+
10701089
>>> td = pd.Timedelta(42, unit='s')
10711090
>>> td.seconds
10721091
42
@@ -1284,6 +1303,13 @@ cdef class _Timedelta(timedelta):
12841303
def components(self):
12851304
"""
12861305
Return a components namedtuple-like.
1306+
1307+
Examples
1308+
--------
1309+
>>> td = pd.Timedelta('2 day 4 min 3 us 42 ns')
1310+
>>> td.components
1311+
Components(days=2, hours=0, minutes=4, seconds=0, milliseconds=0,
1312+
microseconds=3, nanoseconds=42)
12871313
"""
12881314
self._ensure_components()
12891315
# return the named tuple

0 commit comments

Comments
 (0)