Description
Feature Type
-
Adding new functionality to pandas
-
Changing existing functionality in pandas
-
Removing existing functionality in pandas
Problem Description
Currently, a string such as 01-01-2020
is parsed as a delimited date, whereas 1-1-2020
is parsed by dateutil
One consequence of this is that warnings about e.g. dayfirst
aren't shown in the latter case, e.g.:
>>> pd.to_datetime(['13-01-2020'], dayfirst=False)
<stdin>:1: UserWarning: Parsing dates in DD/MM/YYYY format when dayfirst=False (the default) was specified. This may lead to inconsistently parsed dates! Specify a format to ensure consistent parsing.
DatetimeIndex(['2020-01-13'], dtype='datetime64[ns]', freq=None)
>>> pd.to_datetime(['13-1-2020'], dayfirst=False)
DatetimeIndex(['2020-01-13'], dtype='datetime64[ns]', freq=None)
Feature Description
In
pandas/pandas/_libs/tslibs/parsing.pyx
Lines 122 to 173 in 9a2276f
some code could be added to deal with cases where buf
is of length 8 or 9, and either the date or the month are of length 1
Alternative Solutions
Always warn when using dateutil
, but I don't a warning should be necessary here
Additional Context
If we wanted to warn whenever dateutil
is called (e.g. #47828), then this'd really simplify the adjustments necessary to the test suite, as a lot of tests could be kept as they are