Closed
Description
From #50411 (comment)
The documentation of to_datetime
says:
exact : bool, default True
Control howformat
is used:
- If :const:
True
, require an exactformat
match.- If :const:
False
, allow theformat
to match anywhere in the target string.
Based on that, I would expect we don't use anything else in the string that doesn't match the format. But it seems this currently depends on the exact format being used:
>>> pd.to_datetime(["19/may/11 01:00:00"], format="%d/%b/%y", exact=False)
DatetimeIndex(['2011-05-19'], dtype='datetime64[ns]', freq=None)
>>> pd.to_datetime(["2011-05-19 01:00:00"], format="%Y-%m-%d", exact=False)
DatetimeIndex(['2011-05-19 01:00:00'], dtype='datetime64[ns]', freq=None)
(happens both on current main and on 1.5)