-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Index alignment behaviour #39931
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
Labels
Bug
Indexing
Related to indexing on series/frames, not to indexes themselves
Regression
Functionality that used to work in a prior pandas version
Milestone
Comments
Context: We are dispatching to iloc under the hood. Iloc stopped aligning in 1.2 |
@phofl - It seems to me |
DataFrame.setitem does not align, loc behaves fine, but yes this is a regression |
Ah thanks - makes sense. I got the two cases in the OP mixed up. |
4 tasks
simonjayhawkins
added a commit
to simonjayhawkins/pandas
that referenced
this issue
Feb 22, 2021
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug
Indexing
Related to indexing on series/frames, not to indexes themselves
Regression
Functionality that used to work in a prior pandas version
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
CASE 1: Assignment with
.loc
No problem here this is expected behaviour as pandas align data on indices.
CASE 2: Assignment without
.loc
The problem is here. In pandas version
1.2.x
assignment without using.loc
no longer respectsindex
alignment behaviour which was previously respected in version1.1.x
.Problem description
Lets say we want to sort the values of the slice of the dataframe and assign the sorted values back to the original dataframe in-place.
CASE 1
when using assignment with.loc
no effect of sorting the slice is observed in original dataframe which is expected as pandas align data on indices.CASE 2
when using assignment without.loc
the assignment operation no longer respects the alignment of indices which is unexpected behaviour in pandas version1.2.x
Prior to pandas version
1.2.x
lets say in pandas version1.1.5
the assignment operation even without using theloc
respected the index alignment behaviour.Expected Output
In
CASE 2
the expected output should be:As the assignment operation should respect the pandas alignment of indices behaviour.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 7d32926
python : 3.8.6.final.0
python-bits : 64
OS : Linux
OS-release : 5.8.0-44-generic
Version : #50-Ubuntu SMP Tue Feb 9 06:29:41 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_IN
LOCALE : en_IN.ISO8859-1
pandas : 1.2.2
numpy : 1.18.5
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 44.0.0
Cython : None
pytest : 6.2.1
hypothesis : None
sphinx : 3.4.3
blosc : None
feather : None
xlsxwriter : 1.3.5
lxml.etree : 4.6.2
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.18.1
pandas_datareader: 0.9.0
bs4 : 4.9.1
bottleneck : None
fsspec : 0.8.5
fastparquet : 0.5.0
gcsfs : None
matplotlib : 3.3.2
numexpr : None
odfpy : None
openpyxl : 3.0.5
pandas_gbq : None
pyarrow : 2.0.0
pyxlsb : None
s3fs : None
scipy : 1.5.2
sqlalchemy : 1.3.22
tables : None
tabulate : 0.8.7
xarray : 0.16.2
xlrd : 1.2.0
xlwt : None
numba : 0.50.1
The text was updated successfully, but these errors were encountered: