@@ -565,6 +565,55 @@ New Behavior:
565
565
TypeError: Cannot compare 2014-01-01 00:00:00 of
566
566
type <class 'pandas.tslib.Timestamp'> to string column
567
567
568
+ .. _whatsnew_0200.api_breaking.index_order:
569
+
570
+ Index order after DataFrame inner join or Index intersection
571
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
572
+
573
+ The ``DataFrame`` inner join and the ``Index`` intersection, now preserve the
574
+ order of the calling's Index (left) instead of the other's Index (right)
575
+ (:issue:`15582`)
576
+
577
+ Previous Behavior:
578
+
579
+ .. code-block:: ipython
580
+ In [2]: df1 = pd.DataFrame({'a': [20, 10, 0]}, index=[2, 1, 0])
581
+
582
+ In [3]: df2 = pd.DataFrame({'b': [100, 200, 300]}, index=[1, 2, 3])
583
+
584
+ In [4]: df1.join(df2, how='inner')
585
+ Out[4]:
586
+ a b
587
+ 1 10 100
588
+ 2 20 200
589
+
590
+ In [5]: idx1 = pd.Index([5, 3, 2, 4, 1])
591
+
592
+ In [6]: idx2 = pd.Index([4, 7, 6, 5, 3])
593
+
594
+ In [7]: idx1.intersection(idx2)
595
+ Out[7]: Int64Index([4, 5, 3], dtype='int64')
596
+
597
+ New Behavior:
598
+
599
+ .. code-block:: ipython
600
+ In [2]: df1 = pd.DataFrame({'a': [20, 10, 0]}, index=[2, 1, 0])
601
+
602
+ In [3]: df2 = pd.DataFrame({'b': [100, 200, 300]}, index=[1, 2, 3])
603
+
604
+ In [4]: df1.join(df2, how='inner')
605
+ Out[4]:
606
+ a b
607
+ 2 20 200
608
+ 1 10 100
609
+
610
+ In [5]: idx1 = pd.Index([5, 3, 2, 4, 1])
611
+
612
+ In [6]: idx2 = pd.Index([4, 7, 6, 5, 3])
613
+
614
+ In [7]: idx1.intersection(idx2)
615
+ Out[7]: Int64Index([5, 3, 4], dtype='int64')
616
+
568
617
569
618
.. _whatsnew_0200.api:
570
619
0 commit comments