Skip to content

Unexpected TypeError with groupby #31605

Closed
@fran6w

Description

@fran6w

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions