Skip to content

BUG: v1.3.0 to_datetime caching behavior changed compared to v1.2.5 #42639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 3 tasks
stevebachmeier opened this issue Jul 20, 2021 · 2 comments
Closed
2 of 3 tasks
Labels
Duplicate Report Duplicate issue or pull request

Comments

@stevebachmeier
Copy link

stevebachmeier commented Jul 20, 2021

  • 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

@stevebachmeier stevebachmeier added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 20, 2021
@stevebachmeier stevebachmeier changed the title BUG: v1.3.0 to_datetime cacheing behavior changed compared to v1.2.5 BUG: v1.3.0 to_datetime caching behavior changed compared to v1.2.5 Jul 20, 2021
@lithomas1
Copy link
Member

I believe this is patched on master, as isna returns 0 nans on master. I think #42261 fixed it.

@simonjayhawkins
Copy link
Member

I believe this is patched on master, as isna returns 0 nans on master. I think #42261 fixed it.

closing as duplicate of #42259

@simonjayhawkins simonjayhawkins added Duplicate Report Duplicate issue or pull request and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

3 participants