Closed
Description
Expected output
Obtain the most frequent string in a series:
>>> pd.Series('a').value_counts().idxmax()
'a'
Problem
Changing the dtype on the second example from 'object'
to 'string'
breaks this idiom:
>>> pd.Series('a', dtype='string').value_counts().idxmax()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pandas/core/series.py", line 2168, in idxmax
i = nanops.nanargmax(self._values, skipna=skipna)
File "pandas/core/nanops.py", line 71, in _f
return f(*args, **kwargs)
File "pandas/core/nanops.py", line 924, in nanargmax
result = values.argmax(axis)
TypeError: argmax() takes 1 positional argument but 2 were given
The problem is evidently not due to a 'string'
index:
>>> pd.Series([1], index=pd.Series(['a'], dtype='string')).idxmax()
'a'
Output of pd.show_versions()
>>> pd.show_versions()
INSTALLED VERSIONS
------------------
commit : 2a7d3326dee660824a8433ffd01065f8ac37f7d6
python : 3.7.9.final.0
python-bits : 64
OS : Darwin
OS-release : 19.6.0
Version : Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.1.2
numpy : 1.19.2
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 47.1.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.5.2
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None