3
3
v0.23.0
4
4
-------
5
5
6
- This is a major release from 0.21.1 and includes a number of API changes,
6
+ This is a major release from 0.22.0 and includes a number of API changes,
7
7
deprecations, new features, enhancements, and performance improvements along
8
8
with a large number of bug fixes. We recommend that all users upgrade to this
9
9
version.
@@ -240,7 +240,7 @@ The :func:`DataFrame.assign` now accepts dependent keyword arguments for python
240
240
using ``.assign()`` to update an existing column. Previously, callables
241
241
referring to other variables being updated would get the "old" values
242
242
243
- Previous Behaviour :
243
+ Previous behaviour :
244
244
245
245
.. code-block:: ipython
246
246
@@ -253,7 +253,7 @@ The :func:`DataFrame.assign` now accepts dependent keyword arguments for python
253
253
1 3 -2
254
254
2 4 -3
255
255
256
- New Behaviour :
256
+ New behaviour :
257
257
258
258
.. ipython:: python
259
259
@@ -320,6 +320,57 @@ If installed, we now require:
320
320
| openpyxl | 2.4.0 | |
321
321
+-----------------+-----------------+----------+
322
322
323
+ .. _whatsnew_0230.api_breaking.dict_insertion_order:
324
+
325
+ Creating dataframes and series from dicts preserves dict insertion order for python 3.6+
326
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
327
+
328
+ Until Python 3.6, dicts in Python had no formally defined ordering. Python
329
+ version 3.6 and later have changed the ordering definition of dicts, so dicts
330
+ in these newer versions are ordered by insertion order
331
+ (see also `PEP 468 <https://www.python.org/dev/peps/pep-0468/>`_).
332
+ Pandas will from version 0.23 use insertion order, when creating series or
333
+ data frames from dicts (:issue:`19018`) .
334
+
335
+ Previous behaviour (and current behaviour if on Python < 3.6):
336
+
337
+ .. code-block:: ipython
338
+
339
+ In [1]: pd.Series({'Income': 2000,
340
+ ... 'Expenses': -1500,
341
+ ... 'Taxes': -200,
342
+ ... 'Net result': 300})
343
+ Expenses -1500
344
+ Income 2000
345
+ Net result 300
346
+ Taxes -200
347
+ dtype: int64
348
+
349
+ Note the series above is ordered alphabetically by the index values.
350
+
351
+ New behaviour (for Python >= 3.6):
352
+
353
+ .. ipython:: python
354
+
355
+ pd.Series({'Income': 2000,
356
+ 'Expenses': -1500,
357
+ 'Taxes': -200,
358
+ 'Net result': 300})
359
+
360
+ Notice that the series is now ordered by insertion order. This new behaviour is
361
+ used for all relevant pandas types (``Series``, ``DataFrame``, ``SparseSeries``
362
+ and ``SparseDataFrame``).
363
+
364
+ If you wish to retain the old behaviour while using Python >= 3.6, you can use
365
+ ``sort_index``:
366
+
367
+ .. ipython:: python
368
+
369
+ pd.Series({'Income': 2000,
370
+ 'Expenses': -1500,
371
+ 'Taxes': -200,
372
+ 'Net result': 300}).sort_index()
373
+
323
374
.. _whatsnew_0230.api_breaking.deprecate_panel:
324
375
325
376
Deprecate Panel
0 commit comments