Skip to content

Commit 7c7355e

Browse files
committed
run output of date parsers through to_datetime to coerce into acceptable type
1 parent 4fde946 commit 7c7355e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pandas/io/parsers.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,18 +2057,20 @@ def converter(*date_cols):
20572057
infer_datetime_format=infer_datetime_format
20582058
)
20592059
except:
2060-
return lib.try_parse_dates(strs, dayfirst=dayfirst)
2060+
return tools.to_datetime(
2061+
lib.try_parse_dates(strs, dayfirst=dayfirst))
20612062
else:
20622063
try:
2063-
result = date_parser(*date_cols)
2064+
result = tools.to_datetime(date_parser(*date_cols))
20642065
if isinstance(result, datetime.datetime):
20652066
raise Exception('scalar parser')
20662067
return result
20672068
except Exception:
20682069
try:
2069-
return lib.try_parse_dates(_concat_date_cols(date_cols),
2070-
parser=date_parser,
2071-
dayfirst=dayfirst)
2070+
return tools.to_datetime(
2071+
lib.try_parse_dates(_concat_date_cols(date_cols),
2072+
parser=date_parser,
2073+
dayfirst=dayfirst))
20722074
except Exception:
20732075
return generic_parser(date_parser, *date_cols)
20742076

0 commit comments

Comments
 (0)