Closed
Description
after #13033
I left this alone, but should an empty string just be a NaT
(like we do elsewhere), even when a format
is present?
In [1]: td = pd.Series(['May 04', 'Jun 02', ''], index=[1, 2, 3])
In [2]: td
Out[2]:
1 May 04
2 Jun 02
3
dtype: object
In [3]: pd.to_datetime(td, format='%b %y', errors='coerce')
Out[3]:
1 2004-05-01
2 2002-06-01
3 NaT
dtype: datetime64[ns]
In [4]: pd.to_datetime(td, format='%b %y', errors='raise')
ValueError: time data '' does not match format '%b %y' (match)
related is that we don't coerce empty strings here either (and we have an odd error message).
In [1]: pd.to_datetime([1, ''], unit='s', errors='coerce')
Out[1]: DatetimeIndex(['1970-01-01 00:00:01', 'NaT'], dtype='datetime64[ns]', freq=None)
In [2]: pd.to_datetime([1, ''], unit='s')
ValueError: invalid literal for long() with base 10: ''