Skip to content

BUG: pandas.api.types.is_datetime64_any_dtype returns True for 'M' str #60581

@ScottWilliamAnderson

Description

@ScottWilliamAnderson

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
pandas.api.types.is_datetime64_any_dtype('M')  # True

Issue Description

The string 'M' cannot be converted to a datetime using pandas.to_datetime(). It raises the error

Given date string M not likely a datetime present at position 0

I'm unsure what 'M' is supposed to represent? 'Y', 'D' all return False, so I don't think it's strftime strings, perhaps there's another significance I'm missing?

Expected Behavior

I think the 'M' char on its own, should return False

Installed Versions

INSTALLED VERSIONS ------------------ commit : 0f43794 python : 3.11.7.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.26100 machine : AMD64 processor : Intel64 Family 6 Model 186 Stepping 3, GenuineIntel byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : English_United Kingdom.1252

pandas : 2.0.3
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 68.2.2
pip : 23.3.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.4
IPython : 8.26.0
pandas_datareader: None
bs4 : 4.12.3
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugClosing CandidateMay be closeable, needs more eyeballsDatetimeDatetime data dtype

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions