Error Convert data format EN

Asked

Viewed 56 times

-1

Trying to convert str to date in BR format but from the error below. And if I take 'format' it goes in American format:

df = pd.read_csv(‘df.csv',encoding='cp1252', sep=';')

df['Data']= pd.to_datetime('31/09/2019  11:13:01', format='%d/%m/%Y %H:%M:%S')

Error: Valueerror: day is out of range for Month

1 answer

2

The problem is that the date 31/09/2019 is not valid (September only has 30 days).

You can pass the parameter errors="ignore" or errors="coerce" for the function to_datetime.

  • 1

    Great observation.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.