Skip to content

Commit 7d6f7c4

Browse files
committed
coerce to ns resolution only if time unit, not date unit
1 parent b6d07b4 commit 7d6f7c4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pandas/io/parsers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,8 +2153,12 @@ def _try_convert_dates(parser, colspec, data_dict, columns):
21532153

21542154
new_name = '_'.join([str(x) for x in colnames])
21552155
to_parse = [data_dict[c] for c in colnames if c in data_dict]
2156-
2157-
new_col = parser(*to_parse).astype('datetime64[ns]')
2156+
new_col = parser(*to_parse)
2157+
if hasattr(new_col, 'dtype') and any(r in str(new_col.dtype) for r in
2158+
['[h]', '[m]', '[s]',
2159+
'[ms]', '[us]', '[ns]',
2160+
'[ps]', '[fs]', '[as]']):
2161+
new_col = new_col.astype('datetime64[ns]')
21582162
return new_name, new_col, colnames
21592163

21602164

0 commit comments

Comments
 (0)