TypeError on argmax of object dtype (change from 0.20.3)
See original GitHub issue>>> import pandas as pd
>>> pd.Series([0, 0], dtype='object').argmax()
I was doing action = state_action.idxmax()
where state_action was of type ‘pandas.core.series.Series’. When I run in 0.21.0, it gives the following error:
File “/usr/local/lib/python3.5/dist-packages/pandas/core/series.py”, line 1357, in idxmax i = nanops.nanargmax(_values_from_object(self), skipna=skipna) File “/usr/local/lib/python3.5/dist-packages/pandas/core/nanops.py”, line 74, in _f raise TypeError(msg.format(name=f.name.replace(‘nan’, ‘’))) TypeError: reduction operation ‘argmax’ not allowed for this dtype
However, when I downgraded to pandas 0.20.3, it worked just fine. You might wanna look into this. 😃
Issue Analytics
- State:
- Created 6 years ago
- Comments:19 (12 by maintainers)
Top Results From Across the Web
Getting TypeError: reduction operation 'argmax' not allowed ...
TypeError : reduction operation 'argmax' not allowed for this dtype The problem: 1) the type of "mean recall score" is object, you can't...
Read more >What's new in 1.3.0 (July 2, 2021) - Pandas
Calling hash on non-hashable pandas objects will now raise TypeError with the built-in error message (e.g. unhashable type: 'Series' ).
Read more >What's New - Xarray
Fixed “unhashable type” error trying to read NetCDF file with variable having ... Fix bug in where() when passing non-xarray objects with keep_attrs=True...
Read more >Change data type of given numpy array - GeeksforGeeks
In order to change the dtype of the given array object, we will use numpy.astype() function. The function takes an argument which is...
Read more >scikit-learn user guide
The homogeneous NumPy and SciPy data objects currently expected are most efficient ... At change.org we automate the use of scikit-learn's ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As a workaround, you can call
argmax
on the underlying NumPy array:Seeing the same issue as @mar-ses in pandas 1.3.3, i.e.
.max()
works onpd.Timestamp
s, butidxmax()
does not.