BUG: pd.testing.assert_frame_equal(..., check_exact=True) raises AssertionError when comparing numeric ExtensionDtypes · Issue #39410 · pandas-dev/pandas (original) (raw)


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

import pandas as pd

d = {"x": [1, 2]}

df1 = pd.DataFrame(data=d, dtype=pd.UInt32Dtype()) df2 = pd.DataFrame(data=d, dtype=pd.UInt32Dtype())

pd.testing.assert_frame_equal(df1, df2, check_exact=True)

Problem description

The above code raises the following exception:

AssertionError: ndarray Expected type <class 'numpy.ndarray'>, found <class 'pandas.core.arrays.integer.IntegerArray'> instead

Instead, the usage of pd.testing.assert_frame_equal(..., check_exact=True) should not raise an exception when comparing numeric ExtensionDtypes.

Expected Output

No exception.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 9d598a5
python : 3.8.7.final.0
python-bits : 64
OS : Darwin
OS-release : 17.7.0
Version : Darwin Kernel Version 17.7.0: Fri Oct 30 13:34:27 PDT 2020; root:xnu-4570.71.82.8~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.2.1
numpy : 1.19.5
pytz : 2020.5
dateutil : 2.8.1
pip : 20.2.3
setuptools : 49.2.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
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 : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None