Skip to content

Attribute "dtype" are different error with testing.assert_frame_equal #35715

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

Closed
tejasj654 opened this issue Aug 14, 2020 · 2 comments · Fixed by #35750
Closed

Attribute "dtype" are different error with testing.assert_frame_equal #35715

tejasj654 opened this issue Aug 14, 2020 · 2 comments · Fixed by #35750
Labels
Bug ExtensionArray Extending pandas with custom dtypes or arrays. Testing pandas testing functions or related to the test suite
Milestone

Comments

@tejasj654
Copy link

tejasj654 commented Aug 14, 2020

Hi,
When trying testing.assert_frame_equal, I get an assert error.
E Attribute "dtype" are different
E [left]: Int64
E [right]: Int16

However, for assert_frame_equal, I do set the argument check_dtype=False.

From traceback, I can see that assert_extension_array_equal is being called with check_dtype=True which is causing the issue.

I do not have a sample at hand and I will update when I can.

Affected version: 1.1.0
The test cases were / are running fine with 1.0.5

@MarcoGorelli
Copy link
Member

Thanks for the report - the following fails for me on 1.0.5 as well:

>>> import pandas as pd
>>> a = pd.DataFrame({'a': [1]}, dtype='Int64')
>>> b = pd.DataFrame({'a': [1]}, dtype='Int16')
>>> pd.testing.assert_frame_equal(a, b, check_dtype=False)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mgorelli/miniconda3/envs/old-pandas/lib/python3.7/site-packages/pandas/_testing.py", line 1382, in assert_frame_equal
    obj=f'{obj}.iloc[:, {i}] (column name="{col}")',
  File "/home/mgorelli/miniconda3/envs/old-pandas/lib/python3.7/site-packages/pandas/_testing.py", line 1184, in assert_series_equal
    assert_extension_array_equal(left.array, right.array)
  File "/home/mgorelli/miniconda3/envs/old-pandas/lib/python3.7/site-packages/pandas/_testing.py", line 1022, in assert_extension_array_equal
    assert_attr_equal("dtype", left, right, obj="ExtensionArray")
  File "/home/mgorelli/miniconda3/envs/old-pandas/lib/python3.7/site-packages/pandas/_testing.py", line 772, in assert_attr_equal
    raise_assert_detail(obj, msg, left_attr, right_attr)
  File "/home/mgorelli/miniconda3/envs/old-pandas/lib/python3.7/site-packages/pandas/_testing.py", line 915, in raise_assert_detail
    raise AssertionError(msg)
AssertionError: ExtensionArray are different

Attribute "dtype" are different
[left]:  Int64
[right]: Int16
>>> pd.__version__
'1.0.5'

@simonjayhawkins simonjayhawkins added Bug ExtensionArray Extending pandas with custom dtypes or arrays. Testing pandas testing functions or related to the test suite labels Aug 14, 2020
@simonjayhawkins simonjayhawkins added this to the Contributions Welcome milestone Aug 14, 2020
@simonjayhawkins
Copy link
Member

The test cases were / are running fine with 1.0.5

@openskullbox Thanks for the report. labelled as a bug for now. If you show an case where this worked in 1.0.5, that'll be great.

@jreback jreback modified the milestones: Contributions Welcome, 1.1.1 Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug ExtensionArray Extending pandas with custom dtypes or arrays. Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants