The Wayback Machine - https://web.archive.org/web/20210323192843/https://github.com/pandas-dev/pandas/issues/40346
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

BUG: 'groupby' method error #40346

Open
Leejung8763 opened this issue Mar 10, 2021 · 4 comments
Open

BUG: 'groupby' method error #40346

Leejung8763 opened this issue Mar 10, 2021 · 4 comments

Comments

@Leejung8763
Copy link

@Leejung8763 Leejung8763 commented Mar 10, 2021

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

df.groupby('teamId').idxmax()
tmp.groupby('teamId').idxmax()

Problem description

DataFrame df is consist of teamId(int64) and neutralMinionsKilled(int64) and 'tmp' is consist of teamId(Int64) and neutralMinionsKilled(Int64)
df.groupby('teamId').idxmax() is working
But tmp.groupby('teamId').idxmax() is not working and showing 'TypeError: argmax() takes 1 positional argument but 2 were given'

Expected Output

image

Output of pd.show_versions()

[paste the output of pd.show_versions() here leaving a blank line after the details tag]
image

@erfannariman
Copy link
Contributor

@erfannariman erfannariman commented Mar 10, 2021

Can you add a reproducible example as mentioned when you opened the bug report, see link

@Leejung8763
Copy link
Author

@Leejung8763 Leejung8763 commented Mar 13, 2021

tmp = pd.DataFrame({'teamId': [100,100,100,200,200,200],
                   'value': [0,0,0,1,2,0],
                   })
tmp.groupby('teamId').idxmax()

It's working and the results are as follows.
image

But,

tmp = pd.DataFrame({'teamId': [100,100,100,200,200,200],
                   'value': [0,0,0,1,2,0],
                   })
tmp = tmp.convert_dtypes()
tmp.groupby('teamId').idxmax()

It's not working with "TypeError: argmax() takes 1 positional argument but 2 were given" message

@MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Mar 13, 2021

Thanks @Leejung8763 for the report

This works on master, but indeed fails in 1.1.3, will do a bisect

@MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Mar 13, 2021

Fixed in #38195

4749fd611e0a303b7325686901c90e6a362bf3cd is the first bad commit
commit 4749fd611e0a303b7325686901c90e6a362bf3cd
Author: jbrockmendel
Date:   Wed Dec 2 04:11:05 2020 -0800

    BUG: DataFrame.idxmin/idxmax with mixed dtypes (#38195)

Could do with an extra test for this though, pull requests welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants