[Pandas-dev] Proposal to change the default of to_datetime in case of errors from 'ignore' to 'raise'

Joris Van den Bossche jorisvandenbossche at gmail.com
Wed Jul 22 10:59:28 EDT 2015


Hi all,

On github there is a proposal to change the default behaviour of to_datetime
in case of a parsing error from 'ignore' (leaving the values untouched) to
'raise' (raise an error).

As a small example, the current behaviour:

In [5]: pd.to_datetime('2014-30-30', errors='ignore')   # the default now
Out[5]: '2014-30-30'

In [6]: pd.to_datetime('2014-30-30', errors='raise')
...
ValueError: month must be in 1..12


So the proposal would be to change the default to the second case, raising
an error.

Note that this behaviour is already the default when providing your own format
(and so in fact ignoring the value of the errors keyword):

In [7]: pd.to_datetime('2014-30-30', format='%Y-%m-%d')
...
ValueError: time data '2014-30-30' does not match format '%Y-%m-%d'


*Are there any objections to this change? *
*Are there people relying on the fact that, by default, to_datetime returns
the exact original value if parsing does not succeed?*

Best regards,
Joris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pandas-dev/attachments/20150722/a157538c/attachment.html>


More information about the Pandas-dev mailing list