BUG: pd.testing.assert_series_equal has problems with ExtensionArray input #45240
Labels
Bug
ExtensionArray
Extending pandas with custom dtypes or arrays.
Testing
pandas testing functions or related to the test suite
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the master branch of pandas.
Reproducible Example
Issue Description
I am using Pint-Pandas, with a lot of working code. However, my Python unittest test suite doesn't work because pd.testing.assert_series_equal is having trouble with my pd.Series objects.
In the above example there are two cases showing, respectively, a pandas test passing (expected) and failing (expected) based on whether the resulting series matches an expected series. That's the warm-up.
The test case then tests some pint functionality. If the two series are EXACTLY the same, the function works, as shown by
test_pint_series_equality_1
test_pint_series_equality_2
shows that if we dig in past the series to the Extension Arrays, it still works with identical data.test_pint_series_equality_5
shows that if we convert the arrays to numpy arrays, then test test case shows an expected failure when the two different series (converted to numpy arrays) are compared.The problems are with
test_pint_series_equality_3
andtest_pint_series_equality_4
. Both attempt to compare different values, but both lead to ERROR, not FAIL, due to mis-handling of ExtensionArrays. Here's the error message from _3 (using Pandas 1.4.0rc0):Expected Behavior
I expect Pandas to report that the different series are different without giving an ERROR.
Installed Versions
INSTALLED VERSIONS
commit : d023ba7
python : 3.8.3.final.0
python-bits : 64
OS : Linux
OS-release : 4.18.0-305.28.1.el8_4.x86_64
Version : #1 SMP Mon Nov 8 07:45:47 EST 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.4.0rc0
numpy : 1.22.0
pytz : 2021.1
dateutil : 2.8.1
pip : 21.1
setuptools : 56.0.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.6.3
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.3
IPython : 7.22.0
pandas_datareader: None
bs4 : 4.6.3
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : 1.4.10
tables : None
tabulate : 0.8.9
xarray : None
xlrd : None
xlwt : None
numba : None
zstandard : None
I am also using Pint and Pint-Pandas:
The text was updated successfully, but these errors were encountered: