-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Series idxmin() TypeError?Need change type to 'float' #41696
Comments
I tried to replicate the error but can't get it. INPUT: import pandas as pd
import numpy as np
df=pd.DataFrame({'col':['DD182103227','DD082104265'],
'value':[5,4]},dtype=np.int64)
df.set_index('col') OUTPUT: value
col
DD182103227 5
DD082104265 4 INPUT: df.info() OUTPUT: <class 'pandas.core.frame.DataFrame'>
RangeIndex: 2 entries, 0 to 1
Data columns (total 2 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 col 2 non-null object
1 value 2 non-null int64
dtypes: int64(1), object(1)
memory usage: 160.0+ bytes INPUT: df['value'].idxmin() OUTPUT:
INPUT: df['value'].astype('float').idxmin() OUTPUT:
|
@ZurMaD Maybe integer dtypes and missing data causes this problem. But idxmin provides a skipna param and default is True, I don't know why it can't handle integer data. |
Related of #33719 and with a PR in #27801 Uhmm may someone of the main branch take a look? Looks like a BUG as described initially But with example provided in docs works Basically fails when Output of
|
This was fixed by #37924 with tests. (Fix is only in master, will be in 1.3) |
i'm using idxmin() on a series, which is like:
However, when using:
ltc.idxmin()
i got an error:
TypeError: argmin() takes 1 positional argument but 2 were given
when using:
ltc.astype('float').idxmin()
i got the right answer:
'DD092104104'
But the api doesn't say that idxmin() can only use on float data.Why?
The text was updated successfully, but these errors were encountered: