Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
# 51 rows results in missingness
df = pd.DataFrame({'date':['07.30.2020'] + ['30.07.2020']*50})
pd.to_datetime(df.date, dayfirst=True).isna().sum()
# 50 rows results in no missingness
pd.to_datetime(df.date[0:50], dayfirst=True).isna().sum()
# 51 rows with cache=False results in no missingness
pd.to_datetime(df.date, dayfirst=True, cache=False).isna().sum()
Problem description
Starting with v1.3.0 we began running into issues where pd.to_datetime would not convert all dates as expected if there are conflicting formats. It appears that the default behavior of cache=True
behaves differently between the two versions. In v1.3.0 it seems that cache=False
fixes the problem but that slows things down.
Expected Output
We would expect there to be no missingness with the default of cache=True
.
Output of pd.show_versions()
INSTALLED VERSIONS
commit : f00ed8f
python : 3.7.10.final.0
python-bits : 64
OS : Linux
OS-release : 3.10.0-957.12.2.el7.x86_64
Version : #1 SMP Tue May 14 21:24:32 UTC 2019
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.3.0
numpy : 1.21.0
pytz : 2021.1
dateutil : 2.8.2
pip : 21.1.3
setuptools : 52.0.0.post20210125
Cython : None
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 : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
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