Skip to content

BUG: drop_duplicates fails on pyarrow string series created with convert_dtypes #54904

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

Closed
2 of 3 tasks
ghost opened this issue Aug 31, 2023 · 0 comments · Fixed by #54913
Closed
2 of 3 tasks

BUG: drop_duplicates fails on pyarrow string series created with convert_dtypes #54904

ghost opened this issue Aug 31, 2023 · 0 comments · Fixed by #54913
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Bug Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@ghost
Copy link

ghost commented Aug 31, 2023

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

This works fine

>>> s = pd.Series(['A', 'A'], dtype='string[pyarrow]')
>>> s.drop_duplicates()
0    A
dtype: string

However, this raises a NotImplementedError

>>> s = pd.Series(['A', 'A']).convert_dtypes(dtype_backend='pyarrow')
>>> s.drop_duplicates()

Traceback (most recent call last):
File "", line 1, in
File ".../.venv/lib/python3.10/site-packages/pandas/core/series.py", line 2397, in drop_duplicates
result = super().drop_duplicates(keep=keep)
File ".../.venv/lib/python3.10/site-packages/pandas/core/base.py", line 1362, in drop_duplicates
duplicated = self._duplicated(keep=keep)
File ".../.venv/lib/python3.10/site-packages/pandas/core/base.py", line 1368, in _duplicated
return algorithms.duplicated(self._values, keep=keep)
File ".../.venv/lib/python3.10/site-packages/pandas/core/algorithms.py", line 1002, in duplicated
values = values._to_masked() # type: ignore[union-attr]
File ".../.venv/lib/python3.10/site-packages/pandas/core/arrays/arrow/array.py", line 1964, in _to_masked
raise NotImplementedError
NotImplementedError

Issue Description

This appears to be a regression in 2.1.0 as I can't reproduce in 2.0.3.

Expected Behavior

The drop_duplicates method should work regardless of how the pyarrow string series is created.

Installed Versions

INSTALLED VERSIONS

commit : ba1cccd
python : 3.10.10.final.0
python-bits : 64
OS : Darwin
OS-release : 22.5.0
Version : Darwin Kernel Version 22.5.0: Mon Apr 24 20:51:50 PDT 2023; root:xnu-8796.121.2~5/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.UTF-8

pandas : 2.1.0
numpy : 1.25.2
pytz : 2023.3
dateutil : 2.8.2
setuptools : 68.1.2
pip : 23.2.1
Cython : None
pytest : 7.4.0
hypothesis : None
sphinx : 7.1.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.9.7
jinja2 : 3.1.2
IPython : 8.14.0
pandas_datareader : None
bs4 : 4.12.2
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : 2023.1.0
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 13.0.0
pyreadstat : None
pyxlsb : None
s3fs : 2023.1.0
scipy : None
sqlalchemy : 2.0.20
tables : None
tabulate : 0.9.0
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

@ghost ghost added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 31, 2023
@phofl phofl added Regression Functionality that used to work in a prior pandas version Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 31, 2023
@phofl phofl added this to the 2.1.1 milestone Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Bug Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant