Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
We got some inconsistencies with iloc between setting a numpy array and a pandas array
df = pd.DataFrame(data={
'col1': [1, 2, 3, 4],
'col2': [3, 4, 5, 6],
'col3': [6, 7, 8, 9],
})
rhs = pd.array([1, 2, 3])
df.iloc[[1, 2, 3]] = rhs
Problem description
This returns
col1 col2 col3
0 1 3 6
1 1 1 1
2 2 2 2
3 3 3 3
When switching the rhs to a numpy array, this returns
rhs = np.array([1, 2, 3])
col1 col2 col3
0 1 3 6
1 1 2 3
2 1 2 3
3 1 2 3
Same happens when using [[1, 2, 3], :]
as indexer
Expected Output
We should be consistent here, if we want to change iloc for the numpy case I think we need to deprecate?
Is this already known?
cc @jbrockmendel @jorisvandenbossche
Output of pd.show_versions()
pandas : 1.3.0.dev0+1320.gc8e077fa87.dirty
numpy : 1.20.0
pytz : 2020.5
dateutil : 2.8.1
pip : 20.3.3
setuptools : 49.6.0.post20210108
Cython : 0.29.21
pytest : 6.2.1
hypothesis : 6.0.2
sphinx : 3.4.3
blosc : None
feather : None
xlsxwriter : 1.3.7
lxml.etree : 4.6.2
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.19.0
pandas_datareader: None
bs4 : 4.9.3
bottleneck : 1.3.2
fsspec : 0.8.5
fastparquet : 0.5.0
gcsfs : 0.7.1
matplotlib : 3.3.3
numexpr : 2.7.2
odfpy : None
openpyxl : 3.0.6
pandas_gbq : None
pyarrow : 1.0.0
pyxlsb : None
s3fs : 0.4.2
scipy : 1.6.0
sqlalchemy : 1.3.22
tables : 3.6.1
tabulate : 0.8.7
xarray : 0.16.2
xlrd : 2.0.1
xlwt : 1.3.0
numba : 0.52.0
None