Skip to content
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

BUG: to_datetime() warns unnecessarily that format cannot be inferred #61196

Closed
2 of 3 tasks
metazoic opened this issue Mar 28, 2025 · 3 comments
Closed
2 of 3 tasks

BUG: to_datetime() warns unnecessarily that format cannot be inferred #61196

metazoic opened this issue Mar 28, 2025 · 3 comments
Labels
Bug Datetime Datetime data dtype Warnings Warnings that appear or should be added to pandas

Comments

@metazoic
Copy link

metazoic commented Mar 28, 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

pd.to_datetime(['2020-01-01T20:20:20', '2020-01-01T20:21:20'])

Issue Description

This produces the following warning even though the format is inferable:

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.

Digging deeper, this warning occurs only when the year = concatenated hour and minute in the first element of the list, e.g. year = 2020, hour = 20, minute = 20.

Expected Behavior

to_datetime() should behave just as it does when this unique condition does not hold.

Installed Versions

INSTALLED VERSIONS

commit : 0691c5c
python : 3.12.9
python-bits : 64
OS : Darwin
OS-release : 24.3.0
Version : Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:24 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6030
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.2.3
numpy : 2.1.3
pytz : 2024.1
dateutil : 2.9.0.post0
pip : 25.0
Cython : None
sphinx : 7.3.7
IPython : 8.30.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
blosc : None
bottleneck : 1.4.2
dataframe-api-compat : None
fastparquet : None
fsspec : 2024.12.0
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.6
lxml.etree : 5.3.0
matplotlib : 3.10.0
numba : 0.61.0
numexpr : 2.10.1
odfpy : None
openpyxl : 3.1.5
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 19.0.0
pyreadstat : None
pytest : 8.3.4
python-calamine : None
pyxlsb : None
s3fs : 2024.12.0
scipy : 1.15.1
sqlalchemy : 2.0.37
tables : 3.10.2
tabulate : 0.9.0
xarray : 2024.11.0
xlrd : None
xlsxwriter : None
zstandard : 0.23.0
tzdata : 2023.3
qtpy : 2.4.1
pyqt5 : None

@metazoic metazoic added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 28, 2025
@asishm asishm added the Datetime Datetime data dtype label Mar 29, 2025
@asishm
Copy link
Contributor

asishm commented Mar 29, 2025

This seems to be fixed in main

@myenugula
Copy link
Contributor

I've run your reproducible locally and it didn't give me any user warning.

Installed Versions
INSTALLED VERSIONS
------------------
commit                : 543680dcd9af5e4a9443d54204ec21e801652252
python                : 3.11.9
python-bits           : 64
OS                    : Darwin
OS-release            : 24.3.0
Version               : Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6031
machine               : arm64
processor             : arm
byteorder             : little
LC_ALL                : None
LANG                  : None
LOCALE                : en_US.UTF-8

pandas                : 0+untagged.36056.g543680d
numpy                 : 2.2.4
dateutil              : 2.9.0.post0
pip                   : 25.0.1
Cython                : 3.0.12
sphinx                : None
IPython               : None
adbc-driver-postgresql: None
adbc-driver-sqlite    : None
bs4                   : None
blosc                 : None
bottleneck            : None
fastparquet           : None
fsspec                : None
html5lib              : None
hypothesis            : None
gcsfs                 : None
jinja2                : None
lxml.etree            : None
matplotlib            : None
numba                 : None
numexpr               : None
odfpy                 : None
openpyxl              : None
psycopg2              : None
pymysql               : None
pyarrow               : None
pyreadstat            : None
pytest                : None
python-calamine       : None
pytz                  : 2025.2
pyxlsb                : None
s3fs                  : None
scipy                 : None
sqlalchemy            : None
tables                : None
tabulate              : None
xarray                : None
xlrd                  : None
xlsxwriter            : None
zstandard             : None
tzdata                : 2025.2
qtpy                  : None
pyqt5                 : None

@rhshadrach
Copy link
Member

Thanks @asishm and @myenugula - closing.

@rhshadrach rhshadrach added 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 Mar 29, 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

4 participants