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: Index of RHS of series assignment ignored #40184

Closed
isVoid opened this issue Mar 2, 2021 · 2 comments
Closed

BUG: Index of RHS of series assignment ignored #40184

isVoid opened this issue Mar 2, 2021 · 2 comments
Labels
Closing Candidate May be closeable, needs more eyeballs Indexing Related to indexing on series/frames, not to indexes themselves

Comments

@isVoid
Copy link
Contributor

isVoid commented Mar 2, 2021

  • [ 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.


Code Sample, a copy-pastable example

>>> x = pd.Series([1, 2, 3])
>>> y = pd.Series([4, 5, 6], index=[2, 1, 0])
>>> x.iloc[:] = y
>>> x
0    4
1    5
2    6
dtype: int64

Problem description

When assigning a series to another, the index of the RHS should be considered. In this example, the mapping of the RHS is {2: 4, 1: 5, 0: 6}, but such mapping is ignored in the final result.

Expected Output

>>> x
0    6
1    5
2    4

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 3e89b4c
python : 3.7.8.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-76-generic
Version : #86-Ubuntu SMP Fri Jan 17 17:24:28 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : None
LOCALE : en_US.UTF-8

pandas : 1.2.0
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.3
setuptools : 49.6.0.post20200814
Cython : 0.29.21
pytest : 6.0.2
hypothesis : 5.28.0
sphinx : 3.2.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.3.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : 0.8.2
fastparquet : None
gcsfs : None
matplotlib : 3.3.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 1.0.1
pyxlsb : None
s3fs : None
scipy : 1.5.2
sqlalchemy : None
tables : None
tabulate : None
xarray : 0.16.2
xlrd : None
xlwt : None
numba : 0.52.0

@isVoid isVoid added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 2, 2021
@phofl
Copy link
Member

phofl commented Mar 2, 2021

Iloc stopped aligning in 1.2. This was mentioned in the Release Notes

@phofl phofl added Closing Candidate May be closeable, needs more eyeballs Indexing Related to indexing on series/frames, not to indexes themselves and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 2, 2021
@jreback
Copy link
Contributor

jreback commented Mar 3, 2021

yeah for alignment use .loc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closing Candidate May be closeable, needs more eyeballs Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

No branches or pull requests

3 participants