33v0.23.0
44-------
55
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,
77deprecations, new features, enhancements, and performance improvements along
88with a large number of bug fixes. We recommend that all users upgrade to this
99version.
@@ -240,7 +240,7 @@ The :func:`DataFrame.assign` now accepts dependent keyword arguments for python
240240 using ``.assign()`` to update an existing column. Previously, callables
241241 referring to other variables being updated would get the "old" values
242242
243- Previous Behaviour :
243+ Previous behavior :
244244
245245 .. code-block:: ipython
246246
@@ -253,7 +253,7 @@ The :func:`DataFrame.assign` now accepts dependent keyword arguments for python
253253 1 3 -2
254254 2 4 -3
255255
256- New Behaviour :
256+ New behavior :
257257
258258 .. ipython:: python
259259
@@ -320,6 +320,57 @@ If installed, we now require:
320320| openpyxl | 2.4.0 | |
321321+-----------------+-----------------+----------+
322322
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+ DataFrames from dicts (:issue:`19018`) .
334+
335+ Previous behavior (and current behavior 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 behavior (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 behavior is
361+ used for all relevant pandas types (``Series``, ``DataFrame``, ``SparseSeries``
362+ and ``SparseDataFrame``).
363+
364+ If you wish to retain the old behavior 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+
323374.. _whatsnew_0230.api_breaking.deprecate_panel:
324375
325376Deprecate Panel
0 commit comments