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

concat without sort in groupby.py code raises FutureWarning #25174

Closed
aloukina opened this issue Feb 5, 2019 · 8 comments
Closed

concat without sort in groupby.py code raises FutureWarning #25174

aloukina opened this issue Feb 5, 2019 · 8 comments
Labels
Groupby Warnings Warnings that appear or should be added to pandas

Comments

@aloukina
Copy link

aloukina commented Feb 5, 2019

Problem description

There are several calls to concat in groupby.py that do not pass the sort argument. This raises FutureWarning when the function is exectuted. For example:

pandas/core/groupby/groupby.py:1105: 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'.

  result = concat(values, axis=self.axis)

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.8.final.0
python-bits: 64
OS: Darwin
OS-release: 17.7.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.23.4
pytest: None
pip: 18.1
setuptools: 40.6.3
Cython: None
numpy: 1.14.2
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 6.5.0
sphinx: 1.8.2
patsy: 0.5.1
dateutil: 2.7.5
pytz: 2018.9
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.1.2
openpyxl: 2.5.12
xlrd: 1.2.0
xlwt: 1.2.0
xlsxwriter: None
lxml: None
bs4: 4.7.1
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

@WillAyd
Copy link
Member

WillAyd commented Feb 5, 2019

Can you share the code you have to reproduce? I see you are using v0.23.4 this has most likely been fixed in more recent release

@WillAyd WillAyd added the Needs Info Clarification about behavior needed to assess issue label Feb 5, 2019
@aloukina
Copy link
Author

aloukina commented Feb 6, 2019

Here is the corresponding line in master:

result = concat(values, axis=self.axis)

@blu3r4y
Copy link

blu3r4y commented Sep 10, 2019

There are still a lot of calls that are missing the sort argument in groupby.py on master, triggering internal warnings.

The last warning I got in 0.25.1 was here: (it's still the same line as mentioned by @aloukina)

result = concat(values, axis=self.axis)

@TomAugspurger
Copy link
Contributor

@blu3r4y @aloukina do either of you have a reproducible example that generates the error? That'll help in getting it addressed.

@blu3r4y
Copy link

blu3r4y commented Sep 30, 2019

@TomAugspurger sure! (tested with pandas==0.25.1)

import pandas as pd

df = pd.DataFrame({
    "group": ["a", "b", "c"],
    "value": [1, 2, 3]
})

df.groupby("group")["value"].apply(pd.DataFrame)

This yields the FutureWarning in groupby.py:937

result = concat(values, axis=self.axis)

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Sep 30, 2019 via email

@mroeschke mroeschke added Groupby Warnings Warnings that appear or should be added to pandas and removed Needs Info Clarification about behavior needed to assess issue labels Oct 20, 2019
@jbrockmendel
Copy link
Member

Is this closed by #29786?

@jbrockmendel
Copy link
Member

I don't see a warning in master, so closing as closed by #29786. Feel free to ping if the issue reappears and we can re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Groupby Warnings Warnings that appear or should be added to pandas
Projects
None yet
Development

No branches or pull requests

6 participants