1

I have got a pandas serie as follows:

1    29/04/2020 22:16
2    02/05/2020 15:32
3    01/05/2020 6:37
4    02/05/2020 8:00
5    28/04/2020 8:15
6                    
7    06/05/2020 14:29
8    02/05/2020 8:12

I would like to format to date time type:

df['date_time_column'] = pd.to_datetime(df['date_time_column'], format='%d/%m/%Y %H:%M')

But the error occurs in the 6 row who is blank " "

How can I do that stuff skipping the blank rows error and kepping the row in blank?

1 Answer 1

3

Add errors='coerce' for converting not matched datetimes to NaT:

df['date_time_column'] = pd.to_datetime(df['date_time_column'], format='%d/%m/%Y %H:%M', errors='coerce')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.