Skip to content

Commit ce7bd74

Browse files
authored
reindex_like after shape comparison
in assert_frame_equal, if check_like, the former code reindex_like before shape comparison. for example: if left.shape=(2,2), right.shpae(2.0), after reindex_like, left.shape(2,0),right.shape(2,0),then the shape comparison will get wrong result.
1 parent b94186d commit ce7bd74

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pandas/util/testing.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1270,9 +1270,6 @@ def assert_frame_equal(left, right, check_dtype=True,
12701270
assertIsInstance(left, type(right))
12711271
# assert_class_equal(left, right, obj=obj)
12721272

1273-
if check_like:
1274-
left, right = left.reindex_like(right), right
1275-
12761273
# shape comparison (row)
12771274
if left.shape[0] != right.shape[0]:
12781275
raise_assert_detail(obj,
@@ -1288,6 +1285,9 @@ def assert_frame_equal(left, right, check_dtype=True,
12881285
left.columns),
12891286
'{0}, {1}'.format(right.shape[1],
12901287
right.columns))
1288+
1289+
if check_like:
1290+
left, right = left.reindex_like(right), right
12911291

12921292
# index comparison
12931293
assert_index_equal(left.index, right.index, exact=check_index_type,

0 commit comments

Comments
 (0)