Skip to content
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

BUG: concat still sorts columns if they differ #43375

Closed
2 of 3 tasks
mathrick opened this issue Sep 3, 2021 · 2 comments · Fixed by #43833
Closed
2 of 3 tasks

BUG: concat still sorts columns if they differ #43375

mathrick opened this issue Sep 3, 2021 · 2 comments · Fixed by #43833
Assignees
Labels
Bug Index Related to the Index class or subclasses Reshaping Concat, Merge/Join, Stack/Unstack, Explode setops union, intersection, difference, symmetric_difference
Milestone

Comments

@mathrick
Copy link

mathrick commented Sep 3, 2021

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Code Sample, a copy-pastable example

>>> print(pd.concat([pd.DataFrame({i: i}, index=[i]) for i in range(10, 0, -1)], sort=False))
     1    2    3    4    5    6    7    8    9     10
10  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  10.0
9   NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  9.0   NaN
8   NaN  NaN  NaN  NaN  NaN  NaN  NaN  8.0  NaN   NaN
7   NaN  NaN  NaN  NaN  NaN  NaN  7.0  NaN  NaN   NaN
6   NaN  NaN  NaN  NaN  NaN  6.0  NaN  NaN  NaN   NaN
5   NaN  NaN  NaN  NaN  5.0  NaN  NaN  NaN  NaN   NaN
4   NaN  NaN  NaN  4.0  NaN  NaN  NaN  NaN  NaN   NaN
3   NaN  NaN  3.0  NaN  NaN  NaN  NaN  NaN  NaN   NaN
2   NaN  2.0  NaN  NaN  NaN  NaN  NaN  NaN  NaN   NaN
1   1.0  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN   NaN

Problem description

This was marked as fixed in #4588, but concat() still sorts the columns if they differ. The sort argument doesn't seem to have any effect on this.

Expected Output

      10   9    8    7    6    5    4    3    2    1 
10  10.0  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN
9    NaN  9.0  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN
8    NaN  NaN  8.0  NaN  NaN  NaN  NaN  NaN  NaN  NaN
7    NaN  NaN  NaN  7.0  NaN  NaN  NaN  NaN  NaN  NaN
6    NaN  NaN  NaN  NaN  6.0  NaN  NaN  NaN  NaN  NaN
5    NaN  NaN  NaN  NaN  NaN  5.0  NaN  NaN  NaN  NaN
4    NaN  NaN  NaN  NaN  NaN  NaN  4.0  NaN  NaN  NaN
3    NaN  NaN  NaN  NaN  NaN  NaN  NaN  3.0  NaN  NaN
2    NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  2.0  NaN
1    NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  1.0

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 5f648bf
python : 3.8.10.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-77-generic
Version : #86-Ubuntu SMP Thu Jun 17 02:35:03 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8

pandas : 1.3.2
numpy : 1.21.2
pytz : 2021.1
dateutil : 2.8.2
pip : 20.0.2
setuptools : 44.0.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None

@mathrick mathrick added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 3, 2021
@jbrockmendel
Copy link
Member

I'm running into something similar, tentatively lools like indexes.api.union_indexes is ignoring the 'sort' keyword

@simonjayhawkins simonjayhawkins added Index Related to the Index class or subclasses setops union, intersection, difference, symmetric_difference and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 4, 2021
@simonjayhawkins simonjayhawkins added this to the Contributions Welcome milestone Sep 4, 2021
@simonjayhawkins simonjayhawkins added the Reshaping Concat, Merge/Join, Stack/Unstack, Explode label Sep 4, 2021
@CloseChoice
Copy link
Member

take

@jreback jreback modified the milestones: Contributions Welcome, 1.4 Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Index Related to the Index class or subclasses Reshaping Concat, Merge/Join, Stack/Unstack, Explode setops union, intersection, difference, symmetric_difference
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants