|
24 | 24 | from numpy.testing import assert_array_equal
|
25 | 25 |
|
26 | 26 | import pandas as pd
|
27 |
| -from pandas.core.common import is_sequence, array_equivalent, is_list_like, is_number, is_datetimelike_v_numeric |
| 27 | +from pandas.core.common import (is_sequence, array_equivalent, is_list_like, is_number, |
| 28 | + is_datetimelike_v_numeric, is_datetimelike_v_object) |
28 | 29 | import pandas.compat as compat
|
29 | 30 | from pandas.compat import(
|
30 | 31 | filter, map, zip, range, unichr, lrange, lmap, lzip, u, callable, Counter,
|
@@ -688,10 +689,10 @@ def assert_series_equal(left, right, check_dtype=True,
|
688 | 689 | elif check_datetimelike_compat:
|
689 | 690 | # we want to check only if we have compat dtypes
|
690 | 691 | # e.g. integer and M|m are NOT compat, but we can simply check the values in that case
|
691 |
| - if is_datetimelike_v_numeric(left, right): |
692 |
| - # datetime.datetime and pandas.tslib.Timestamp may hold |
693 |
| - # equivalent values but fail assert_frame_equal |
694 |
| - if not all([x == y for x, y in zip(left, right)]): |
| 692 | + if is_datetimelike_v_numeric(left, right) or is_datetimelike_v_object(left, right): |
| 693 | + |
| 694 | + # datetimelike may have different objects (e.g. datetime.datetime vs Timestamp) but will compare equal |
| 695 | + if not Index(left.values).equals(Index(right.values)): |
695 | 696 | raise AssertionError(
|
696 | 697 | '[datetimelike_compat=True] {0} is not equal to {1}.'.format(left.values,
|
697 | 698 | right.values))
|
|
0 commit comments