I have a column with a birthdate. Some are N.A, some 01.01.2016
but some contain 01.01.2016 01:01:01
Filtering the N.A. values works fine. But handling the different date formats seems clumsy. Is it possible to have pandas handle these gracefully and e.g. for a birthdate only interpret the date and not fail?
Asked
Active
Viewed 1,349 times
1

Georg Heiler
- 16,916
- 36
- 162
- 292
-
Probably already answered here: http://stackoverflow.com/a/32854764/6614295 – jotasi Aug 30 '16 at 08:12
1 Answers
4
pd.to_datetime()
will handle multiple formats
>>> ser = pd.Series(['NaT', '01.01.2016', '01.01.2016 01:01:01'])
>>> pd.to_datetime(ser)
0 NaT
1 2016-01-01 00:00:00
2 2016-01-01 01:01:01
dtype: datetime64[ns]

Asish M.
- 2,588
- 1
- 16
- 31