Pandas version checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pandas.
-
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
series = pd.Series(["red", "yellow", "red", "green", pd.NA], dtype="string[pyarrow]")
series.mode()
=======================================
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../pandas/core/series.py", line 2072, in mode
res_values = values._mode(dropna=dropna)
File ".../pandas/core/arrays/arrow/array.py", line 1311, in _mode
modes = pc.mode(data, pc.count_distinct(data).as_py())
File ".../pyarrow/compute.py", line 255, in wrapper
return func.call(args, options, memory_pool)
File "pyarrow/_compute.pyx", line 355, in pyarrow._compute.Function.call
File "pyarrow/error.pxi", line 144, in pyarrow.lib.pyarrow_internal_check_status
File "pyarrow/error.pxi", line 121, in pyarrow.lib.check_status
pyarrow.lib.ArrowNotImplementedError: Function 'mode' has no kernel matching input types (string)
Issue Description
Using the string[pyarrow]
dtype prevents the usage of mode()
.
Expected Behavior
I would expect the mode()
function to work and return a pd.Series
with the mode being identified as red
.
Installed Versions
INSTALLED VERSIONS
------------------
commit : b2a26ecc538cbd04ef256b6e0de78aac700ec286
python : 3.8.13.final.0
python-bits : 64
OS : Darwin
OS-release : 21.6.0
Version : Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.0.0.dev0+1430.gb2a26ecc5
numpy : 1.23.4
pytz : 2022.5
dateutil : 2.8.2
setuptools : 62.6.0
pip : 23.0
Cython : None
pytest : 7.0.1
hypothesis : None
sphinx : 5.1.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.4.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli : None
fastparquet : None
fsspec : 2022.5.0
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 9.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.10.0
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : None
qtpy : 2.1.0
pyqt5 : None
Comment From: mroeschke
Thanks for the report but as the traceback shows this is an issue with Arrow as this is not implement by pyarrow. Closing as an upstream issue, but this would be good to report to the Arrow issue tracker.