Skip to content

Stop concat from attempting to sort mismatched columns by default #20613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
May 1, 2018
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
913723b
Stop concat from attempting to sort mismatched columns by default
brycepg Apr 5, 2018
5da763f
Merge remote-tracking branch 'upstream/master' into brycepg-master
TomAugspurger Apr 26, 2018
02b2db9
Updates
TomAugspurger Apr 26, 2018
a497763
Test fallout
TomAugspurger Apr 26, 2018
954a1b6
Updated append
TomAugspurger Apr 26, 2018
2a20377
versionadded
TomAugspurger Apr 26, 2018
35570c4
Squash more test warnings
TomAugspurger Apr 27, 2018
983d0c1
py2 compat
TomAugspurger Apr 27, 2018
27d2d32
Merge remote-tracking branch 'upstream/master' into brycepg-master
TomAugspurger Apr 27, 2018
4960e3f
Document outer is not affected
TomAugspurger Apr 27, 2018
8bbbdd5
Docs
TomAugspurger Apr 27, 2018
dcfa6d0
Sort for intersection
TomAugspurger Apr 28, 2018
2eaeb1e
More tests
TomAugspurger Apr 28, 2018
bc7dd48
Test fixup.
TomAugspurger Apr 29, 2018
b3f95dd
Stop concat from attempting to sort mismatched columns by default
brycepg Apr 5, 2018
f37d7ef
Updates
TomAugspurger Apr 26, 2018
e467f91
Test fallout
TomAugspurger Apr 26, 2018
058fae5
Updated append
TomAugspurger Apr 26, 2018
04e5151
versionadded
TomAugspurger Apr 26, 2018
c864679
Squash more test warnings
TomAugspurger Apr 27, 2018
7e975c9
py2 compat
TomAugspurger Apr 27, 2018
a8ba430
Document outer is not affected
TomAugspurger Apr 27, 2018
62b1e7b
Docs
TomAugspurger Apr 27, 2018
0ace673
Sort for intersection
TomAugspurger Apr 28, 2018
d5cafdf
More tests
TomAugspurger Apr 28, 2018
ce8ff05
Test fixup.
TomAugspurger Apr 29, 2018
ce756d4
ugh
TomAugspurger Apr 29, 2018
362e84d
quoting
TomAugspurger Apr 30, 2018
0210d33
Clarify
TomAugspurger Apr 30, 2018
06772b4
Removed unnescesary check
TomAugspurger Apr 30, 2018
95cdf67
Merge remote-tracking branch 'upstream/master' into brycepg-master
TomAugspurger Apr 30, 2018
d10f5bd
Merge remote-tracking branch 'brycepg/master' into brycepg-master
TomAugspurger Apr 30, 2018
e47cbb9
Prune tests
TomAugspurger Apr 30, 2018
0182c98
Default sort
TomAugspurger Apr 30, 2018
7e58998
Make both tests happy
TomAugspurger Apr 30, 2018
5b58e75
Explicit columns
TomAugspurger Apr 30, 2018
074d03c
List of series
TomAugspurger Apr 30, 2018
5e1b024
test, fix pivot
TomAugspurger May 1, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Docs
  • Loading branch information
TomAugspurger committed Apr 27, 2018
commit 8bbbdd52a9d223215eef408c75f2526ce828e19b
22 changes: 14 additions & 8 deletions doc/source/merging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ Set logic on the other axes
~~~~~~~~~~~~~~~~~~~~~~~~~~~

When gluing together multiple DataFrames, you have a choice of how to handle
the other axes (other than the one being concatenated). This can be done in
the other axes (other than the one being concatenated). This can be done in
the following three ways:

- Take the (sorted) union of them all, ``join='outer'``. This is the default
- Take the union of them all, ``join='outer'``. This is the default
option as it results in zero information loss.
- Take the intersection, ``join='inner'``.
- Use a specific index, as passed to the ``join_axes`` argument.
Expand All @@ -167,10 +167,10 @@ behavior:
.. ipython:: python

df4 = pd.DataFrame({'B': ['B2', 'B3', 'B6', 'B7'],
'D': ['D2', 'D3', 'D6', 'D7'],
'F': ['F2', 'F3', 'F6', 'F7']},
index=[2, 3, 6, 7])
result = pd.concat([df1, df4], axis=1)
'D': ['D2', 'D3', 'D6', 'D7'],
'F': ['F2', 'F3', 'F6', 'F7']},
index=[2, 3, 6, 7])
result = pd.concat([df1, df4], axis=1, sort=False)


.. ipython:: python
Expand All @@ -181,8 +181,14 @@ behavior:
labels=['df1', 'df4'], vertical=False);
plt.close('all');

Note that the row indexes have been unioned and sorted. Here is the same thing
with ``join='inner'``:
.. versionchanged:: 0.23.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this a note (maybe a warning)


The default behavior with ``join='outer'`` is to sort the other axis
(columns in this case). In a future version of pandas, the default will
be to not sort. We specified ``sort=False`` to opt in to the new
behavior now.

Here is the same thing with ``join='inner'``:

.. ipython:: python

Expand Down