Skip to content

Unexpected TypeError with groupby #31605

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

Closed
fran6w opened this issue Feb 3, 2020 · 5 comments · Fixed by #31621
Closed

Unexpected TypeError with groupby #31605

fran6w opened this issue Feb 3, 2020 · 5 comments · Fixed by #31621
Labels
Duplicate Report Duplicate issue or pull request good first issue Needs Tests Unit test(s) needed to prevent regressions
Milestone

Comments

@fran6w
Copy link

fran6w commented Feb 3, 2020

Code Sample, a copy-pastable example if possible

# Your code here
import numpy as np
import pandas as pd

def fct(group):
    return group[1].values.flatten()

df = pd.DataFrame([('A', 1), ('A', 2), ('A', 3), ('B', 4), ('B', 5), ('C', np.nan),])
df.groupby(0).apply(fct)

Problem description

This code works with pandas 0.25.1 BUT NOT with pandas 1.0.0.
With pandas 1.0.0, the output is:
TypeError: copy() takes no keyword arguments

Expected Output

With pandas 0.25.1, the output is:
Series:
0
A [1.0, 2.0, 3.0]
B [4.0, 5.0]
C [nan]

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.8.1.final.0
python-bits : 64
OS : Windows
OS-release : 7
machine : AMD64
processor : Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : fr_FR.cp1252

pandas : 1.0.0
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 45.1.0.post20200127
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10.3
IPython : 7.11.1
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.1.1
numexpr : None
odfpy : None
openpyxl : 3.0.3
pandas_gbq : None
pyarrow : None
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : 1.3.2
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : None

@fjetter
Copy link
Member

fjetter commented Feb 3, 2020

I believe this is already fixed by #31456

@jorisvandenbossche
Copy link
Member

Indeed, I can confirm this is working again. Fix will be in 1.0.1 normally released tomorrow.

@jorisvandenbossche jorisvandenbossche added the Duplicate Report Duplicate issue or pull request label Feb 3, 2020
@jorisvandenbossche jorisvandenbossche added this to the 1.0.1 milestone Feb 3, 2020
@jorisvandenbossche
Copy link
Member

But thanks for the report!

@jorisvandenbossche
Copy link
Member

Actually, will keep this open as an issue to add an additional test case (it can be added next to the ones added in #31456)

@jorisvandenbossche jorisvandenbossche added good first issue Needs Tests Unit test(s) needed to prevent regressions labels Feb 3, 2020
@TomAugspurger
Copy link
Contributor

TomAugspurger commented Feb 3, 2020

Moving off 1.0.1, since the extra test case needn't hold up the release.

@TomAugspurger TomAugspurger modified the milestones: 1.0.1, Contributions Welcome Feb 3, 2020
@jreback jreback modified the milestones: Contributions Welcome, 1.1 Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request good first issue Needs Tests Unit test(s) needed to prevent regressions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants