|
13 | 13 | RNGContext)
|
14 | 14 | from pandas.compat import is_platform_windows
|
15 | 15 |
|
16 |
| -# let's get meta. |
17 |
| - |
18 | 16 |
|
19 | 17 | class TestAssertAlmostEqual(tm.TestCase):
|
20 | 18 |
|
@@ -594,6 +592,20 @@ def _assert_not_equal(self, a, b, **kwargs):
|
594 | 592 | self.assertRaises(AssertionError, assert_frame_equal, a, b, **kwargs)
|
595 | 593 | self.assertRaises(AssertionError, assert_frame_equal, b, a, **kwargs)
|
596 | 594 |
|
| 595 | + def test_equal_with_different_row_order(self): |
| 596 | + # check_like=True ignores row-column orderings |
| 597 | + df1 = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}, |
| 598 | + index=['a', 'b', 'c']) |
| 599 | + df2 = pd.DataFrame({'A': [3, 2, 1], 'B': [6, 5, 4]}, |
| 600 | + index=['c', 'b', 'a']) |
| 601 | + |
| 602 | + self._assert_equal(df1, df2, check_like=True) |
| 603 | + self._assert_not_equal(df1, df2) |
| 604 | + |
| 605 | + def test_not_equal_with_different_shape(self): |
| 606 | + self._assert_not_equal(pd.DataFrame({'A': [1, 2, 3]}), |
| 607 | + pd.DataFrame({'A': [1, 2, 3, 4]})) |
| 608 | + |
597 | 609 | def test_index_dtype(self):
|
598 | 610 | df1 = DataFrame.from_records(
|
599 | 611 | {'a': [1, 2], 'c': ['l1', 'l2']}, index=['a'])
|
@@ -621,19 +633,9 @@ def test_frame_equal_message(self):
|
621 | 633 |
|
622 | 634 | expected = """DataFrame are different
|
623 | 635 |
|
624 |
| -DataFrame shape \\(number of rows\\) are different |
625 |
| -\\[left\\]: 3, RangeIndex\\(start=0, stop=3, step=1\\) |
626 |
| -\\[right\\]: 4, RangeIndex\\(start=0, stop=4, step=1\\)""" |
627 |
| - |
628 |
| - with assertRaisesRegexp(AssertionError, expected): |
629 |
| - assert_frame_equal(pd.DataFrame({'A': [1, 2, 3]}), |
630 |
| - pd.DataFrame({'A': [1, 2, 3, 4]})) |
631 |
| - |
632 |
| - expected = """DataFrame are different |
633 |
| -
|
634 |
| -DataFrame shape \\(number of columns\\) are different |
635 |
| -\\[left\\]: 2, Index\\(\\[u?'A', u?'B'\\], dtype='object'\\) |
636 |
| -\\[right\\]: 1, Index\\(\\[u?'A'\\], dtype='object'\\)""" |
| 636 | +DataFrame shape mismatch |
| 637 | +\\[left\\]: \\(3, 2\\) |
| 638 | +\\[right\\]: \\(3, 1\\)""" |
637 | 639 |
|
638 | 640 | with assertRaisesRegexp(AssertionError, expected):
|
639 | 641 | assert_frame_equal(pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}),
|
|
0 commit comments