BUG: wrong item assignment by repeated key with ArrowExtensionArray · Issue #58530 · pandas-dev/pandas (original) (raw)

Pandas version checks

Reproducible Example

import pandas as pd import pyarrow as pa

series = pd.Series([0,1,2,3,4,5], dtype=pd.ArrowDtype(pa.int64())) series[[0, 0, 1]] = [-1, -1, -2]

pd.testing.assert_series_equal( series, # [-1, -1, 2, 3, 4, 5] pd.Series([-1, -2, 2, 3, 4, 5], dtype=pd.ArrowDtype(pa.int64())), )

Issue Description

With series backed by ArrowExtensionArray, assignment with a non-unique key causes incorrect results.

Expected Behavior

Assignment works like in numpy

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:12:49 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6020
machine : arm64
processor : arm
byteorder : little
LC_ALL : en_US.UTF-8
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 : None
IPython : 8.23.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.8.4
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 16.0.0
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.13.0
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None