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

kylebarron opened this issue Jul 17, 2018 · 4 comments

Concatenation warning still appears with sort=False #21952

kylebarron opened this issue Jul 17, 2018 · 4 comments


Copy link

@kylebarron kylebarron commented Jul 17, 2018

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']) = 'index_name'
b = pd.DataFrame(
    {'col4': [1, 2, 3, 4, 5],
     'col3': [1, 2, 3, 4, 5]},
    index=['a', 'b', 'c', 'd', 'e']) = 'index_name'
c = pd.DataFrame(
    {'col5': [1, 2, 3, 4, 5]},
    index=['f', 'g', 'h', 'i', 'j']) = '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/ 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'.

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()


commit: None
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

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

Copy link

@WillAyd 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 removed this from the Contributions Welcome milestone Jul 20, 2018
@jorisvandenbossche jorisvandenbossche added this to the 0.24.0 milestone Jul 20, 2018
@jreback jreback removed this from the 0.24.0 milestone Dec 2, 2018
@jreback jreback added this to the Contributions Welcome milestone Dec 2, 2018
Copy link

@dylancis dylancis commented Jul 26, 2019

Same issue here.


Copy link

@TomAugspurger TomAugspurger commented Jul 29, 2019

It seems we fail to pass sort through here

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

class TestConcatenate:


Copy link

@ncernek 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
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

7 participants