Description
Code Sample
import pandas as pd
df = pd.DataFrame({'a': [1,2], 'b': [2,3]})
df_coldiff = pd.DataFrame({'a': [1,2], 'ZZZ': [2,3]})
pd.testing.assert_frame_equal(df, df_coldiff, obj='myobj')
# raises:
# AssertionError: myobj.columns are different
#
# myobj.columns values are different (50.0 %)
# [left]: Index(['a', 'b'], dtype='object')
# [right]: Index(['a', 'ZZZ'], dtype='object')
df_valuediff = pd.DataFrame({'a': [1,2], 'b': [2,999]})
pd.testing.assert_frame_equal(df, df_valuediff, obj='myobj')
# raises:
# AssertionError: DataFrame.iloc[:, 1] are different
#
# DataFrame.iloc[:, 1] values are different (50.0 %)
# [left]: [2, 3]
# [right]: [2, 999]
Problem description
In the first example where the column names differ, the 'myobj' label is used in the assertion message.
In the second example where the values differ, the 'myobj' label does not appear.
It looks to me like these strings should be formatted with obj
instead of hardcoded with DataFrame
?
https://github.com/pandas-dev/pandas/blob/master/pandas/util/testing.py#L1252
https://github.com/pandas-dev/pandas/blob/master/pandas/util/testing.py#L1267
Expected Output
I expected the assertion message for the second example to be:
# AssertionError: myobj.iloc[:, 1] are different
#
# myobj.iloc[:, 1] values are different (50.0 %)
# [left]: [2, 3]
# [right]: [2, 999]
Output of pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.7.1.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-52-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_CA.UTF-8
LOCALE: en_CA.UTF-8
pandas: 0.24.2
pytest: 4.4.1
pip: 19.1
setuptools: 41.0.1
Cython: 0.29.7
numpy: 1.16.3
scipy: 1.2.1
pyarrow: None
xarray: None
IPython: 7.5.0
sphinx: 2.0.1
patsy: 0.5.1
dateutil: 2.8.0
pytz: 2019.1
blosc: None
bottleneck: 1.2.1
tables: 3.5.1
numexpr: 2.6.9
feather: None
matplotlib: 3.0.3
openpyxl: 2.6.1
xlrd: 1.2.0
xlwt: 1.3.0
xlsxwriter: 1.1.7
lxml.etree: 4.3.3
bs4: 4.7.1
html5lib: 1.0.1
sqlalchemy: 1.3.5
pymysql: None
psycopg2: None
jinja2: 2.10.1
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None