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

Concatenation warning still appears with sort=False #21952

Closed
kylebarron opened this issue Jul 17, 2018 · 4 comments · Fixed by #27702
Closed

Concatenation warning still appears with sort=False #21952

kylebarron opened this issue Jul 17, 2018 · 4 comments · Fixed by #27702
Labels
good first issue Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@kylebarron
Copy link
Contributor

Code Sample, a copy-pastable example if possible

a = pd.DataFrame(
    {'col1': [1, 2, 3, 4, 5],
     'col2': [6, 7, 8, 9, 10]},
    index=['a', 'c', 'e', 'f', 'i'])
a.index.name = 'index_name'
b = pd.DataFrame(
    {'col4': [1, 2, 3, 4, 5],
     'col3': [1, 2, 3, 4, 5]},
    index=['a', 'b', 'c', 'd', 'e'])
b.index.name = 'index_name'
c = pd.DataFrame(
    {'col5': [1, 2, 3, 4, 5]},
    index=['f', 'g', 'h', 'i', 'j'])
c.index.name = 'index_name'
dfs = [a, b, c]

dfs[0].join(dfs[1:], how='outer', sort=True)
dfs[0].join(dfs[1:], how='outer', sort=False)

Problem description

Running either or the last two lines still shows the warning. For example, the last step gives me

/homes/nber/barronk-dua51929/local/anaconda3/envs/medicare_utils/lib/python3.6/site-packages/pandas/core/frame.py:6369: FutureWarning: Sorting because non-concatenation axis is not aligned. A future version
of pandas will change to not sort by default.

To accept the future behavior, pass 'sort=False'.

To retain the current behavior and silence the warning, pass 'sort=True'.

  verify_integrity=True)
col1	col2	col4	col3	col5
a	1.0	6.0	1.0	1.0	NaN
b	NaN	NaN	2.0	2.0	NaN
c	2.0	7.0	3.0	3.0	NaN
d	NaN	NaN	4.0	4.0	NaN
e	3.0	8.0	5.0	5.0	NaN
f	4.0	9.0	NaN	NaN	1.0
g	NaN	NaN	NaN	NaN	2.0
h	NaN	NaN	NaN	NaN	3.0
i	5.0	10.0	NaN	NaN	4.0
j	NaN	NaN	NaN	NaN	5.0

By passing sort=False, the warning should be hidden. From here I believed that passing True or False for the sort argument should silence the warning.

I'm using pandas 0.23.3.

Expected Output

Silenced warning.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.5.final.0
python-bits: 64
OS: Linux
OS-release: 2.6.32-696.18.7.el6.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.23.3
pytest: 3.6.2
pip: 9.0.1
setuptools: 39.2.0
Cython: 0.28.4
numpy: 1.14.5
scipy: 1.1.0
pyarrow: 0.9.0
xarray: None
IPython: 6.4.0
sphinx: 1.7.5
patsy: 0.5.0
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.2.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: 4.2.3
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: 0.1.5
pandas_gbq: None
pandas_datareader: None

@WillAyd WillAyd added the Reshaping Concat, Merge/Join, Stack/Unstack, Explode label Jul 17, 2018
@WillAyd
Copy link
Member

WillAyd commented Jul 17, 2018

Thanks for the report - investigation and PRs are always welcome!

@WillAyd WillAyd added this to the Contributions Welcome milestone Jul 17, 2018
@jorisvandenbossche jorisvandenbossche modified the milestones: Contributions Welcome, 0.24.0 Jul 20, 2018
@jreback jreback modified the milestones: 0.24.0, Contributions Welcome Dec 2, 2018
@dylancis
Copy link

dylancis commented Jul 26, 2019

Same issue here.

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Jul 29, 2019

It seems we fail to pass sort through here

https://github.com/pandas-dev/pandas/blob/master/pandas/core/frame.py#L7217-L7223

A PR adding that with tests would be quite welcome. Tests can go in

class TestConcatenate:
.

@jorisvandenbossche jorisvandenbossche modified the milestones: Contributions Welcome, 0.25.1 Jul 30, 2019
@ncernek
Copy link
Contributor

ncernek commented Aug 1, 2019

Looking to start contributing. I'll work on a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants