-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Subtracting two series with unordered index and all-nan index produces unexpected result #38439
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
Comments
Thanks @ssche for the report. Tested with 0.25.3 and also giving same output as master. |
This is a bug in MultiIndex.equals, which may hide a Bug in Series.align.
returns
while
returns
e.g. not duplicating the NaN rows. I think the second one is the correct one? |
Seems like the above example is consistent now? Could use a test possibly
|
take |
I have tried to test the code and the assertion has no errors
|
@trevorkask Great news and thanks for sharing your results. I think the intent is now to create a test case (your test case above) to lock in behaviour in Pandas. Do you need assistance? |
Yes, please |
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.
Code Sample, a copy-pastable example
Problem description
When combining two series with both the same index and with an all-nan index row at different positions, the result of the arithmetic operation (
+
,-
,/
) is not as expected. The issue can be worked around by sorting both indices (series.sort_index). I tried a different example with unordered indices, but without the all-nan index row and the result is as expected (so it's not an issue of the unsorted indices).Expected Output
Operands should be aligned as per index (despite all nan-rows in the index).
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 65f0463
python : 3.8.6.final.0
python-bits : 64
OS : Linux
OS-release : 5.9.11-200.fc33.x86_64
Version : #1 SMP Tue Nov 24 18:18:01 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_AU.UTF-8
LOCALE : en_AU.UTF-8
pandas : 1.2.0.dev0+1441.g65f0463d3
numpy : 1.19.4
pytz : 2020.4
dateutil : 2.8.1
pip : 20.2.4
setuptools : 50.3.2
Cython : 0.29.21
pytest : 5.1.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 0.9.6
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.8.3 (dt dec pq3 ext lo64)
jinja2 : 2.11.2
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : 1.3.1
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : 2.7.1
odfpy : None
openpyxl : 1.8.6
pandas_gbq : None
pyarrow : 1.0.1
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.3.12
tables : 3.6.1
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: