Skip to content

Commit cd8a61f

Browse files
DOC: further clean-up of removed timedelta attributes in whatsnew docs
1 parent 9f439f0 commit cd8a61f

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

doc/source/whatsnew/v0.15.0.txt

+15-7
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,25 @@ This type is very similar to how ``Timestamp`` works for ``datetimes``. It is a
111111

112112
``Timedelta`` scalars (and ``TimedeltaIndex``) component fields are *not the same* as the component fields on a ``datetime.timedelta`` object. For example, ``.seconds`` on a ``datetime.timedelta`` object returns the total number of seconds combined between ``hours``, ``minutes`` and ``seconds``. In contrast, the pandas ``Timedelta`` breaks out hours, minutes, microseconds and nanoseconds separately.
113113

114-
.. ipython:: python
114+
.. code-block:: python
115115

116116
# Timedelta accessor
117-
tds = Timedelta('31 days 5 min 3 sec')
118-
tds.minutes
119-
tds.seconds
117+
In [9]: tds = Timedelta('31 days 5 min 3 sec')
118+
119+
In [10]: tds.minutes
120+
Out[10]: 5L
121+
122+
In [11]: tds.seconds
123+
Out[11]: 3L
120124

121125
# datetime.timedelta accessor
122126
# this is 5 minutes * 60 + 3 seconds
123-
tds.to_pytimedelta().seconds
127+
In [12]: tds.to_pytimedelta().seconds
128+
Out[12]: 303
129+
130+
**Note**: this is no longer true starting from v0.16.0, where full
131+
compatibility with ``datetime.timedelta`` is introduced. See the
132+
:ref:`0.16.0 whatsnew entry <whatsnew_0160.api_breaking.timedelta>`
124133

125134
.. warning::
126135

@@ -149,8 +158,7 @@ Access fields for a ``Timedelta``
149158
.. ipython:: python
150159

151160
td = Timedelta('1 hour 3m 15.5us')
152-
td.hours
153-
td.minutes
161+
td.seconds
154162
td.microseconds
155163
td.nanoseconds
156164

doc/source/whatsnew/v0.16.0.txt

+20-5
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,29 @@ New features
2222

2323
.. _whatsnew_0160.api:
2424

25-
Backwards incompatible API changes
26-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27-
2825
.. _whatsnew_0160.api_breaking:
2926

30-
- In v0.15.0 a new scalar type ``Timedelta`` was introduced, that is a sub-class of ``datetime.timedelta``. Mentioned :ref:`here <whatsnew_0150.timedeltaindex>` was a notice of an API change w.r.t. the ``.seconds`` accessor. The intent was to provide a user-friendly set of accessors that give the 'natural' value for that unit, e.g. if you had a ``Timedelta('1 day, 10:11:12')``, then ``.seconds`` would return 12. However, this is at odds with the definition of ``datetime.timedelta``, which defines ``.seconds`` as ``10 * 3600 + 11 * 60 + 12 == 36672``.
27+
Backwards incompatible API changes
28+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3129

32-
So in v0.16.0, we are restoring the API to match that of ``datetime.timedelta``. Further, the component values are still available through the ``.components`` accessor. This affects the ``.seconds`` and ``.microseconds`` accessors, and removes the ``.hours``, ``.minutes``, ``.milliseconds`` accessors. These changes affect ``TimedeltaIndex`` and the Series ``.dt`` accessor as well. (:issue:`9185`, :issue:`9139`)
30+
.. _whatsnew_0160.api_breaking.timedelta:
31+
32+
- In v0.15.0 a new scalar type ``Timedelta`` was introduced, that is a
33+
sub-class of ``datetime.timedelta``.
34+
Mentioned :ref:`here <whatsnew_0150.timedeltaindex>` was a notice of an API
35+
change w.r.t. the ``.seconds`` accessor. The intent was to provide a
36+
user-friendly set of accessors that give the 'natural' value for that unit,
37+
e.g. if you had a ``Timedelta('1 day, 10:11:12')``, then ``.seconds`` would
38+
return 12. However, this is at odds with the definition of
39+
``datetime.timedelta``, which defines ``.seconds`` as
40+
``10 * 3600 + 11 * 60 + 12 == 36672``.
41+
42+
So in v0.16.0, we are restoring the API to match that of
43+
``datetime.timedelta``. Further, the component values are still available
44+
through the ``.components`` accessor. This affects the ``.seconds`` and
45+
``.microseconds`` accessors, and removes the ``.hours``, ``.minutes``,
46+
``.milliseconds`` accessors. These changes affect ``TimedeltaIndex``
47+
and the Series ``.dt`` accessor as well. (:issue:`9185`, :issue:`9139`)
3348

3449
Previous Behavior
3550

0 commit comments

Comments
 (0)