Skip to content

Commit f0d9d03

Browse files
Albert Villanova del Moraljreback
Albert Villanova del Moral
authored andcommitted
Add whatsnew
1 parent c96306d commit f0d9d03

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

doc/source/whatsnew/v0.20.0.txt

+49
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,55 @@ New Behavior:
738738
TypeError: Cannot compare 2014-01-01 00:00:00 of
739739
type <class 'pandas.tslib.Timestamp'> to string column
740740

741+
.. _whatsnew_0200.api_breaking.index_order:
742+
743+
Index order after DataFrame inner join or Index intersection
744+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
745+
746+
The ``DataFrame`` inner join and the ``Index`` intersection, now preserve the
747+
order of the calling's Index (left) instead of the other's Index (right)
748+
(:issue:`15582`)
749+
750+
Previous Behavior:
751+
752+
.. code-block:: ipython
753+
In [2]: df1 = pd.DataFrame({'a': [20, 10, 0]}, index=[2, 1, 0])
754+
755+
In [3]: df2 = pd.DataFrame({'b': [100, 200, 300]}, index=[1, 2, 3])
756+
757+
In [4]: df1.join(df2, how='inner')
758+
Out[4]:
759+
a b
760+
1 10 100
761+
2 20 200
762+
763+
In [5]: idx1 = pd.Index([5, 3, 2, 4, 1])
764+
765+
In [6]: idx2 = pd.Index([4, 7, 6, 5, 3])
766+
767+
In [7]: idx1.intersection(idx2)
768+
Out[7]: Int64Index([4, 5, 3], dtype='int64')
769+
770+
New Behavior:
771+
772+
.. code-block:: ipython
773+
In [2]: df1 = pd.DataFrame({'a': [20, 10, 0]}, index=[2, 1, 0])
774+
775+
In [3]: df2 = pd.DataFrame({'b': [100, 200, 300]}, index=[1, 2, 3])
776+
777+
In [4]: df1.join(df2, how='inner')
778+
Out[4]:
779+
a b
780+
2 20 200
781+
1 10 100
782+
783+
In [5]: idx1 = pd.Index([5, 3, 2, 4, 1])
784+
785+
In [6]: idx2 = pd.Index([4, 7, 6, 5, 3])
786+
787+
In [7]: idx1.intersection(idx2)
788+
Out[7]: Int64Index([5, 3, 4], dtype='int64')
789+
741790

742791
.. _whatsnew_0200.api:
743792

0 commit comments

Comments
 (0)