-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Open
Labels
DatetimeDatetime data dtypeDatetime data dtypeEnhancementError ReportingIncorrect or improved errors from pandasIncorrect or improved errors from pandasTestingpandas testing functions or related to the test suitepandas testing functions or related to the test suite
Description
Is your feature request related to a problem?
I wish I could use pandas.testing.assert_frame_equal
to determine which of my datetime64[ns]
columns are not equal when comparing two dataframes. Currently the output is AssertionError: numpy array are different
without indicating which columns are different.
Describe the solution you'd like
When two dataframes with datetime64[ns]
columns are compared using pandas.testing.assert_frame_equal
and there are different values, the output should also have the column name that has this difference, e.g. AssertionError: DataFrame.iloc[:, 1] (column name="b") are different
.
Additional context
Minimal reproducible code below. If you change one of the datetime
values to an integer, the dtype of the column will be object
, in which case, the desired behaviour is shown.
import pandas as pd
from pandas.testing import assert_frame_equal
df_left = pd.DataFrame({'a': [1, 2], 'b': [
datetime(2021, 1, 1),
# 1,
datetime(2021, 1, 2)
]})
df_right = pd.DataFrame({'a': [1, 2], 'b': [
datetime(2021, 1, 1),
# 1,
datetime(2021, 1, 3)
]})
assert_frame_equal(left=df_left, right=df_right)
Metadata
Metadata
Assignees
Labels
DatetimeDatetime data dtypeDatetime data dtypeEnhancementError ReportingIncorrect or improved errors from pandasIncorrect or improved errors from pandasTestingpandas testing functions or related to the test suitepandas testing functions or related to the test suite