-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the master branch of pandas.
Reproducible Example
import pandas as pd
s1 = pd.Series(['2020-01-01 00:00:00'])
s2 = pd.to_datetime(s1)
pd.testing.assert_series_equal(s1,s2,check_dtype=False)Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/nfs/vjawa/pandas/pandas/_testing/asserters.py", line 1078, in assert_series_equal
_testing.assert_almost_equal(
File "pandas/_libs/testing.pyx", line 53, in pandas._libs.testing.assert_almost_equal
cpdef assert_almost_equal(a, b,
File "pandas/_libs/testing.pyx", line 168, in pandas._libs.testing.assert_almost_equal
raise_assert_detail(obj, msg, lobj, robj, index_values=index_values)
File "/home/nfs/vjawa/pandas/pandas/_testing/asserters.py", line 666, in raise_assert_detail
raise AssertionError(msg)
AssertionError: Series are different
Series values are different (100.0 %)
[index]: [0]
[left]: [2020-01-01 00:00:00]
[right]: <DatetimeArray>
['2020-01-01 00:00:00']
Length: 1, dtype: datetime64[ns]Issue Description
BUG: assert_series_equal b/w datetime column with equivalent object column fails with check_dtype=False
When trying to compare two series where one is an object and the other is an equivalent date-time created using pd.to_datetime , we get a unexpected AssertionError.
Expected Behavior
I would expect that we pass the assertion.
Installed Versions
INSTALLED VERSIONS
commit : 36d5c9b
python : 3.9.7.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-76-generic
Version : #86-Ubuntu SMP Fri Jan 17 17:24:28 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.4.0.dev0+745.g36d5c9b8e5
numpy : 1.20.3
pytz : 2021.1
dateutil : 2.8.2
pip : 21.2.4
setuptools : 58.0.4
Cython : 0.29.24
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : 1.3.2
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : 2.7.3
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None