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: .mode(dropna=False) doesn't work with nullable integers #58926

Closed
2 of 3 tasks
theemathas opened this issue Jun 5, 2024 · 2 comments · Fixed by #61132
Closed
2 of 3 tasks

BUG: .mode(dropna=False) doesn't work with nullable integers #58926

theemathas opened this issue Jun 5, 2024 · 2 comments · Fixed by #61132
Assignees
Labels
Bug NA - MaskedArrays Related to pd.NA and nullable extension arrays

Comments

@theemathas
Copy link

Pandas version checks

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

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

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd
series = pd.Series([1, 1, 2, 3]).astype('Int64')
print(series.mode(dropna=False))

Issue Description

This code causes the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/REDACTED/lib/python3.12/site-packages/pandas/core/series.py", line 2333, in mode
    res_values = values._mode(dropna=dropna)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/REDACTED/lib/python3.12/site-packages/pandas/core/arrays/masked.py", line 1112, in _mode
    result, res_mask = mode(self._data, dropna=dropna, mask=self._mask)
    ^^^^^^^^^^^^^^^^
ValueError: too many values to unpack (expected 2)

Expected Behavior

The code should print the modes of the input series.

Installed Versions

INSTALLED VERSIONS

commit : d9cdd2e
python : 3.12.3.final.0
python-bits : 64
OS : Darwin
OS-release : 23.4.0
Version : Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.2.2
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : None
pip : 24.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 : 3.1.4
IPython : 8.25.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.3
pandas_gbq : None
pyarrow : None
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None

@theemathas theemathas added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 5, 2024
@Aloqeely
Copy link
Member

Aloqeely commented Jun 5, 2024

Thanks for the report! I can reproduce this on main, PRs to fix are welcome!

@Aloqeely Aloqeely added NA - MaskedArrays Related to pd.NA and nullable extension arrays and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 5, 2024
JJLLWW added a commit to JJLLWW/pandas that referenced this issue Jun 5, 2024
@halogen22
Copy link
Contributor

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug NA - MaskedArrays Related to pd.NA and nullable extension arrays
Projects
None yet
3 participants