You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a b
0 1 10
1 2 20
2 3 30
a b
1 2 20
0 1 999
2 3 30
Traceback (most recent call last):
<removed stack trace>
raise AssertionError(msg)
AssertionError: DataFrame.iloc[:, 1] are different
DataFrame.iloc[:, 1] values are different (33.33333 %)
[left]: [20, 10, 30]
[right]: [20, 999, 30]
Problem description
When running assert_frame_equal with check_like=True the error message can be unhelpful if the column or index order differs (or worse, both).
#29218 has greatly helped the issue with column reordering, although it could be insufficient if check_names is false and the column names differ (but this is probably a small edge case).
However, row (index) reordering is still an issue. As the output above demonstrates, it is not obvious that the left column has been reordered. In most cases the user could probably work it out but it is not as clear as it could be.
Possible Solution
One solution would be to explicitly state the index values in the output. This would probably have to affect the output of assert_series_equal as well. This would be quite a significant change to the output though so it may be a sledgehammer to crack a nut.
DataFrame.iloc[:, 1] values are different (33.33333 %)
[index]: [1, 0, 2]
[left]: [20, 10, 30]
[right]: [20, 999, 30]
A side effect of including the index would be that you could avoid having to display the entire sequence for low numbers of differences in long sequences - although I'm not suggesting that be part of this change.
Is this worth doing and is the above a sensible solution?
Output of pd.show_versions()
[paste the output of pd.show_versions() here below this line]
INSTALLED VERSIONS
commit : None
python : 3.7.5.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
Code Sample, a copy-pastable example if possible
Generates the output:
Problem description
When running assert_frame_equal with check_like=True the error message can be unhelpful if the column or index order differs (or worse, both).
#29218 has greatly helped the issue with column reordering, although it could be insufficient if check_names is false and the column names differ (but this is probably a small edge case).
However, row (index) reordering is still an issue. As the output above demonstrates, it is not obvious that the left column has been reordered. In most cases the user could probably work it out but it is not as clear as it could be.
Possible Solution
One solution would be to explicitly state the index values in the output. This would probably have to affect the output of assert_series_equal as well. This would be quite a significant change to the output though so it may be a sledgehammer to crack a nut.
A side effect of including the index would be that you could avoid having to display the entire sequence for low numbers of differences in long sequences - although I'm not suggesting that be part of this change.
Is this worth doing and is the above a sensible solution?
Output of
pd.show_versions()
[paste the output of
pd.show_versions()
here below this line]INSTALLED VERSIONS
commit : None
python : 3.7.5.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 0.25.2
numpy : 1.17.3
pytz : 2019.3
dateutil : 2.8.0
pip : 19.3.1
setuptools : 41.6.0.post20191030
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
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
The text was updated successfully, but these errors were encountered: