Skip to content

Commit f63933c

Browse files
committed
Correct an issue when coerce=True did not return a NaT
1 parent 62ca4f2 commit f63933c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pandas/tseries/tools.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import pandas.tslib as tslib
99
import pandas.core.common as com
1010
from pandas.compat import StringIO, callable
11+
from pandas.tslib import NaT, iNaT
1112
import pandas.compat as compat
1213

1314
try:
@@ -320,7 +321,7 @@ def _convert_listlike(arg, box, format):
320321
except ValueError:
321322
# Only raise this error if the user provided the
322323
# datetime format, and not when it was inferred
323-
if not infer_datetime_format:
324+
if not infer_datetime_format and not coerce:
324325
raise
325326

326327
if result is None and (format is None or infer_datetime_format):
@@ -349,7 +350,11 @@ def _convert_listlike(arg, box, format):
349350
elif com.is_list_like(arg):
350351
return _convert_listlike(arg, box, format)
351352

352-
return _convert_listlike(np.array([ arg ]), box, format)[0]
353+
try:
354+
return _convert_listlike(np.array([ arg ]), box, format)[0]
355+
except ValueError as e:
356+
if not coerce:
357+
raise e
353358

354359
class DateParseError(ValueError):
355360
pass

0 commit comments

Comments
 (0)