Skip to content

Commit 470dbaa

Browse files
authored
combine row and column shape comparison
1 parent ce7bd74 commit 470dbaa

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

pandas/util/testing.py

+5-14
Original file line numberDiff line numberDiff line change
@@ -1270,21 +1270,12 @@ def assert_frame_equal(left, right, check_dtype=True,
12701270
assertIsInstance(left, type(right))
12711271
# assert_class_equal(left, right, obj=obj)
12721272

1273-
# shape comparison (row)
1274-
if left.shape[0] != right.shape[0]:
1273+
# shape comparison
1274+
if left.shape != right.shape:
12751275
raise_assert_detail(obj,
1276-
'DataFrame shape (number of rows) are different',
1277-
'{0}, {1}'.format(left.shape[0], left.index),
1278-
'{0}, {1}'.format(right.shape[0], right.index))
1279-
# shape comparison (columns)
1280-
if left.shape[1] != right.shape[1]:
1281-
raise_assert_detail(obj,
1282-
'DataFrame shape (number of columns) '
1283-
'are different',
1284-
'{0}, {1}'.format(left.shape[1],
1285-
left.columns),
1286-
'{0}, {1}'.format(right.shape[1],
1287-
right.columns))
1276+
'DataFrame shape mismatch',
1277+
'({0}, {1})'.format(*left.shape),
1278+
'({0}, {1})'.format(*right.shape))
12881279

12891280
if check_like:
12901281
left, right = left.reindex_like(right), right

0 commit comments

Comments
 (0)