Skip to content

Commit d02ac0b

Browse files
committed
DOC: more v0.16.0 changes
1 parent d876a9f commit d02ac0b

File tree

1 file changed

+91
-101
lines changed

1 file changed

+91
-101
lines changed

doc/source/whatsnew/v0.16.0.txt

Lines changed: 91 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -164,62 +164,120 @@ from a ``scipy.sparse.coo_matrix``:
164164
ss = SparseSeries.from_coo(A)
165165
ss
166166

167-
.. _whatsnew_0160.api:
168-
169167
.. _whatsnew_0160.api_breaking:
170168

171169
Backwards incompatible API changes
172170
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
173171

174172
.. _whatsnew_0160.api_breaking.timedelta:
175173

176-
- In v0.15.0 a new scalar type ``Timedelta`` was introduced, that is a
177-
sub-class of ``datetime.timedelta``.
178-
Mentioned :ref:`here <whatsnew_0150.timedeltaindex>` was a notice of an API
179-
change w.r.t. the ``.seconds`` accessor. The intent was to provide a
180-
user-friendly set of accessors that give the 'natural' value for that unit,
181-
e.g. if you had a ``Timedelta('1 day, 10:11:12')``, then ``.seconds`` would
182-
return 12. However, this is at odds with the definition of
183-
``datetime.timedelta``, which defines ``.seconds`` as
184-
``10 * 3600 + 11 * 60 + 12 == 36672``.
185-
186-
So in v0.16.0, we are restoring the API to match that of
187-
``datetime.timedelta``. Further, the component values are still available
188-
through the ``.components`` accessor. This affects the ``.seconds`` and
189-
``.microseconds`` accessors, and removes the ``.hours``, ``.minutes``,
190-
``.milliseconds`` accessors. These changes affect ``TimedeltaIndex``
191-
and the Series ``.dt`` accessor as well. (:issue:`9185`, :issue:`9139`)
174+
In v0.15.0 a new scalar type ``Timedelta`` was introduced, that is a
175+
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``.
176+
177+
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`)
178+
179+
Previous Behavior
180+
181+
.. code-block:: python
182+
183+
In [2]: t = pd.Timedelta('1 day, 10:11:12.100123')
184+
185+
In [3]: t.days
186+
Out[3]: 1
187+
188+
In [4]: t.seconds
189+
Out[4]: 12
190+
191+
In [5]: t.microseconds
192+
Out[5]: 123
193+
194+
New Behavior
195+
196+
.. ipython:: python
197+
198+
t = pd.Timedelta('1 day, 10:11:12.100123')
199+
t.days
200+
t.seconds
201+
t.microseconds
202+
203+
Using ``.components`` allows the full component access
204+
205+
.. ipython:: python
206+
207+
t.components
208+
t.components.seconds
209+
210+
Indexing Changes
211+
~~~~~~~~~~~~~~~~
212+
213+
.. _whatsnew_0160.api_breaking.indexing:
214+
215+
The behavior of a small sub-set of edge cases for using ``.loc`` have changed (:issue:`8613`). Furthermore we have improved the content of the error messages that are raised:
216+
217+
- slicing with ``.loc`` where the start and/or stop bound is not found in the index is now allowed; this previously would raise a ``KeyError``. This makes the behavior the same as ``.ix`` in this case. This change is only for slicing, not when indexing with a single label.
218+
219+
.. ipython:: python
220+
221+
df = DataFrame(np.random.randn(5,4),
222+
columns=list('ABCD'),
223+
index=date_range('20130101',periods=5))
224+
df
225+
s = Series(range(5),[-2,-1,1,2,3])
226+
s
192227

193228
Previous Behavior
194229

195230
.. code-block:: python
196231

197-
In [2]: t = pd.Timedelta('1 day, 10:11:12.100123')
232+
In [4]: df.loc['2013-01-02':'2013-01-10']
233+
KeyError: 'stop bound [2013-01-10] is not in the [index]'
234+
235+
In [6]: s.loc[-10:3]
236+
KeyError: 'start bound [-10] is not the [index]'
237+
238+
New Behavior
239+
240+
.. ipython:: python
241+
242+
df.loc['2013-01-02':'2013-01-10']
243+
s.loc[-10:3]
198244

199-
In [3]: t.days
200-
Out[3]: 1
245+
- allow slicing with float-like values on an integer index for ``.ix``. Previously this was only enabled for ``.loc``:
201246

202-
In [4]: t.seconds
203-
Out[4]: 12
247+
Previous Behavior
204248

205-
In [5]: t.microseconds
206-
Out[5]: 123
249+
.. code-block:: python
250+
251+
In [8]: s.ix[-1.0:2]
252+
TypeError: the slice start value [-1.0] is not a proper indexer for this index type (Int64Index)
207253

208254
New Behavior
209255

210256
.. ipython:: python
211257

212-
t = pd.Timedelta('1 day, 10:11:12.100123')
213-
t.days
214-
t.seconds
215-
t.microseconds
258+
s.ix[-1.0:2]
216259

217-
Using ``.components`` allows the full component access
260+
- provide a useful exception for indexing with an invalid type for that index when using ``.loc``. For example trying to use ``.loc`` on an index of type ``DatetimeIndex`` or ``PeriodIndex`` or ``TimedeltaIndex``, with an integer (or a float).
218261

219-
.. ipython:: python
262+
Previous Behavior
263+
264+
.. code-block:: python
220265

221-
t.components
222-
t.components.seconds
266+
In [4]: df.loc[2:3]
267+
KeyError: 'start bound [2] is not the [index]'
268+
269+
New Behavior
270+
271+
.. code-block:: python
272+
273+
In [4]: df.loc[2:3]
274+
TypeError: Cannot do slice indexing on <class 'pandas.tseries.index.DatetimeIndex'> with <type 'int'> keys
275+
276+
277+
API Changes
278+
~~~~~~~~~~~
279+
280+
.. _whatsnew_0160.api:
223281

224282
- ``Index.duplicated`` now returns ``np.array(dtype=bool)`` rather than ``Index(dtype=object)`` containing ``bool`` values. (:issue:`8875`)
225283
- ``DataFrame.to_json`` now returns accurate type serialisation for each column for frames of mixed dtype (:issue:`9037`)
@@ -242,7 +300,6 @@ Backwards incompatible API changes
242300
- ``DatetimeIndex``, ``PeriodIndex`` and ``TimedeltaIndex.summary`` now output the same format. (:issue:`9116`)
243301
- ``TimedeltaIndex.freqstr`` now output the same string format as ``DatetimeIndex``. (:issue:`9116`)
244302

245-
246303
- Bar and horizontal bar plots no longer add a dashed line along the info axis. The prior style can be achieved with matplotlib's ``axhline`` or ``axvline`` methods (:issue:`9088`).
247304

248305

@@ -307,73 +364,6 @@ Backwards incompatible API changes
307364
- ``Series.describe`` for categorical data will now give counts and frequencies of 0, not ``NaN``, for unused categories (:issue:`9443`)
308365

309366

310-
Indexing Changes
311-
~~~~~~~~~~~~~~~~
312-
313-
.. _whatsnew_0160.api_breaking.indexing:
314-
315-
The behavior of a small sub-set of edge cases for using ``.loc`` have changed (:issue:`8613`). Furthermore we have improved the content of the error messages that are raised:
316-
317-
- slicing with ``.loc`` where the start and/or stop bound is not found in the index is now allowed; this previously would raise a ``KeyError``. This makes the behavior the same as ``.ix`` in this case. This change is only for slicing, not when indexing with a single label.
318-
319-
.. ipython:: python
320-
321-
df = DataFrame(np.random.randn(5,4),
322-
columns=list('ABCD'),
323-
index=date_range('20130101',periods=5))
324-
df
325-
s = Series(range(5),[-2,-1,1,2,3])
326-
s
327-
328-
Previous Behavior
329-
330-
.. code-block:: python
331-
332-
In [4]: df.loc['2013-01-02':'2013-01-10']
333-
KeyError: 'stop bound [2013-01-10] is not in the [index]'
334-
335-
In [6]: s.loc[-10:3]
336-
KeyError: 'start bound [-10] is not the [index]'
337-
338-
New Behavior
339-
340-
.. ipython:: python
341-
342-
df.loc['2013-01-02':'2013-01-10']
343-
s.loc[-10:3]
344-
345-
- allow slicing with float-like values on an integer index for ``.ix``. Previously this was only enabled for ``.loc``:
346-
347-
Previous Behavior
348-
349-
.. code-block:: python
350-
351-
In [8]: s.ix[-1.0:2]
352-
TypeError: the slice start value [-1.0] is not a proper indexer for this index type (Int64Index)
353-
354-
New Behavior
355-
356-
.. ipython:: python
357-
358-
s.ix[-1.0:2]
359-
360-
- provide a useful exception for indexing with an invalid type for that index when using ``.loc``. For example trying to use ``.loc`` on an index of type ``DatetimeIndex`` or ``PeriodIndex`` or ``TimedeltaIndex``, with an integer (or a float).
361-
362-
Previous Behavior
363-
364-
.. code-block:: python
365-
366-
In [4]: df.loc[2:3]
367-
KeyError: 'start bound [2] is not the [index]'
368-
369-
New Behavior
370-
371-
.. code-block:: python
372-
373-
In [4]: df.loc[2:3]
374-
TypeError: Cannot do slice indexing on <class 'pandas.tseries.index.DatetimeIndex'> with <type 'int'> keys
375-
376-
377367
.. _whatsnew_0160.deprecations:
378368

379369
Deprecations

0 commit comments

Comments
 (0)