You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/release.rst
+1
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,7 @@ Highlights include:
59
59
- ``Series.to_coo/from_coo`` methods to interact with ``scipy.sparse``, see :ref:`here <whatsnew_0160.enhancements.sparse>`
60
60
- Backwards incompatible change to ``Timedelta`` to conform the ``.seconds`` attribute with ``datetime.timedelta``, see :ref:`here <whatsnew_0160.api_breaking.timedelta>`
61
61
- Changes to the ``.loc`` slicing API to conform with the behavior of ``.ix`` see :ref:`here <whatsnew_0160.api_breaking.indexing>`
62
+
- Changes to the default for ordering in the ``Categorical`` constructor, see :ref:`here <whatsnew_0160.api_breaking.categorical>`
62
63
63
64
See the :ref:`v0.16.0 Whatsnew <whatsnew_0160>` overview or the issue tracker on GitHub for an extensive list
64
65
of all API changes, enhancements and bugs that have been fixed in 0.16.0.
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v0.16.0.txt
+129
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ users upgrade to this version.
13
13
* ``Series.to_coo/from_coo`` methods to interact with ``scipy.sparse``, see :ref:`here <whatsnew_0160.enhancements.sparse>`
14
14
* Backwards incompatible change to ``Timedelta`` to conform the ``.seconds`` attribute with ``datetime.timedelta``, see :ref:`here <whatsnew_0160.api_breaking.timedelta>`
15
15
* Changes to the ``.loc`` slicing API to conform with the behavior of ``.ix`` see :ref:`here <whatsnew_0160.api_breaking.indexing>`
16
+
* Changes to the default for ordering in the ``Categorical`` constructor, see :ref:`here <whatsnew_0160.api_breaking.categorical>`
16
17
17
18
- Check the :ref:`API Changes <whatsnew_0160.api>` and :ref:`deprecations <whatsnew_0160.deprecations>` before updating
18
19
@@ -367,6 +368,134 @@ API Changes
367
368
- ``Series.describe`` for categorical data will now give counts and frequencies of 0, not ``NaN``, for unused categories (:issue:`9443`)
368
369
369
370
371
+
Categorical Changes
372
+
~~~~~~~~~~~~~~~~~~~
373
+
374
+
.. _whatsnew_0160.api_breaking.categorical:
375
+
376
+
In prior versions, ``Categoricals`` that had an unspecified ordering (meaning no ``ordered`` keyword was passed) were defaulted as ``ordered`` Categoricals. Going forward, the ``ordered`` keyword in the ``Categorical`` constructor will default to ``False``. Ordering must now be explicit.
377
+
378
+
Furthermore, previously you *could* change the ``ordered`` attribute of a Categorical by just setting the attribute, e.g. ``cat.ordered=True``; This is now deprecated and you should use ``cat.as_ordered()`` or ``cat.as_unordered()``. These will by default return a **new** object and not modify the existing object. (:issue:`9347`, :issue:`9190`)
379
+
380
+
Previous Behavior
381
+
382
+
.. code-block:: python
383
+
384
+
In [3]: s = Series([0,1,2], dtype='category')
385
+
386
+
In [4]: s
387
+
Out[4]:
388
+
0 0
389
+
1 1
390
+
2 2
391
+
dtype: category
392
+
Categories (3, int64): [0 < 1 < 2]
393
+
394
+
In [5]: s.cat.ordered
395
+
Out[5]: True
396
+
397
+
In [6]: s.cat.ordered = False
398
+
399
+
In [7]: s
400
+
Out[7]:
401
+
0 0
402
+
1 1
403
+
2 2
404
+
dtype: category
405
+
Categories (3, int64): [0, 1, 2]
406
+
407
+
New Behavior
408
+
409
+
.. ipython:: python
410
+
411
+
s = Series([0,1,2], dtype='category')
412
+
s
413
+
s.cat.ordered
414
+
s = s.cat.as_ordered()
415
+
s
416
+
s.cat.ordered
417
+
418
+
# you can set in the constructor of the Categorical
419
+
s = Series(Categorical([0,1,2],ordered=True))
420
+
s
421
+
s.cat.ordered
422
+
423
+
For ease of creation of series of categorical data, we have added the ability to pass keywords when calling ``.astype()``. These are passed directly to the constructor.
424
+
425
+
.. ipython:: python
426
+
427
+
s = Series(["a","b","c","a"]).astype('category',ordered=True)
428
+
s
429
+
s = Series(["a","b","c","a"]).astype('category',categories=list('abcdef'),ordered=False)
430
+
s
431
+
432
+
Indexing Changes
433
+
~~~~~~~~~~~~~~~~
434
+
435
+
.. _whatsnew_0160.api_breaking.indexing:
436
+
437
+
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:
438
+
439
+
- 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.
440
+
441
+
.. ipython:: python
442
+
443
+
df = DataFrame(np.random.randn(5,4),
444
+
columns=list('ABCD'),
445
+
index=date_range('20130101',periods=5))
446
+
df
447
+
s = Series(range(5),[-2,-1,1,2,3])
448
+
s
449
+
450
+
Previous Behavior
451
+
452
+
.. code-block:: python
453
+
454
+
In [4]: df.loc['2013-01-02':'2013-01-10']
455
+
KeyError: 'stop bound [2013-01-10] is not in the [index]'
456
+
457
+
In [6]: s.loc[-10:3]
458
+
KeyError: 'start bound [-10] is not the [index]'
459
+
460
+
New Behavior
461
+
462
+
.. ipython:: python
463
+
464
+
df.loc['2013-01-02':'2013-01-10']
465
+
s.loc[-10:3]
466
+
467
+
- allow slicing with float-like values on an integer index for ``.ix``. Previously this was only enabled for ``.loc``:
468
+
469
+
Previous Behavior
470
+
471
+
.. code-block:: python
472
+
473
+
In [8]: s.ix[-1.0:2]
474
+
TypeError: the slice start value [-1.0] is not a proper indexer for this index type (Int64Index)
475
+
476
+
New Behavior
477
+
478
+
.. ipython:: python
479
+
480
+
s.ix[-1.0:2]
481
+
482
+
- 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).
483
+
484
+
Previous Behavior
485
+
486
+
.. code-block:: python
487
+
488
+
In [4]: df.loc[2:3]
489
+
KeyError: 'start bound [2] is not the [index]'
490
+
491
+
New Behavior
492
+
493
+
.. code-block:: python
494
+
495
+
In [4]: df.loc[2:3]
496
+
TypeError: Cannot do slice indexing on <class 'pandas.tseries.index.DatetimeIndex'> with <type 'int'> keys
0 commit comments