Skip to content

BUG: guess_datetime_format cannot infer iso 8601 format #61403

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
Thomath opened this issue May 7, 2025 · 1 comment
Closed
2 of 3 tasks

BUG: guess_datetime_format cannot infer iso 8601 format #61403

Thomath opened this issue May 7, 2025 · 1 comment
Labels
Bug Datetime Datetime data dtype Warnings Warnings that appear or should be added to pandas

Comments

@Thomath
Copy link

Thomath commented May 7, 2025

Pandas version checks

  • 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 main branch of pandas.

Reproducible Example

import pandas as pd 

# UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.
pd.to_datetime(
    pd.Series(['2025-05-05 20:25:22+00:00', '2025-05-05 12:04:52+00:00'])
)

# no warning
pd.to_datetime(
    pd.Series(['2025-05-05 20:25:22+00:00'])
)

# No warning
pd.to_datetime(
    pd.Series(['2025-05-05 12:03:08+00:00', '2025-05-05 12:04:52+00:00']),
)

Issue Description

When running pd.to_datetime(pd.Series(['2025-05-05 20:25:22+00:00', '2025-05-05 12:04:52+00:00'])) the following warning is risen:

UserWarning: Could not infer format, so each element will be parsed individually, falling back to dateutil. To ensure parsing is consistent and as-expected, please specify a format.

This is because guess_datetime_format cannot infer a format for the first given timestamp '2025-05-05 20:25:22+00:00'.

Expected Behavior

No warning is risen.

Installed Versions

INSTALLED VERSIONS

commit : 0691c5c
python : 3.12.10
python-bits : 64
OS : Linux
OS-release : 6.8.0-58-generic
Version : #60~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 28 16:09:21 UTC 2
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.2.3
numpy : 1.26.4
pytz : 2025.2
dateutil : 2.9.0.post0
pip : 25.0.1
Cython : None
sphinx : None
IPython : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.6
lxml.etree : None
matplotlib : 3.10.1
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : 2.9.10
pymysql : None
pyarrow : None
pyreadstat : None
pytest : 8.3.5
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.15.2
sqlalchemy : 2.0.40
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2025.2
qtpy : None
pyqt5 : None

@Thomath Thomath added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels May 7, 2025
@rhshadrach
Copy link
Member

Thanks for the report. I can reproduce on 2.2.x, but this warning does not appear on main. This will be fixed in pandas 3.0. Closing.

@rhshadrach rhshadrach added Datetime Datetime data dtype Warnings Warnings that appear or should be added to pandas and removed Needs Triage Issue that has not been reviewed by a pandas team member labels May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Warnings Warnings that appear or should be added to pandas
Projects
None yet
Development

No branches or pull requests

2 participants