I am reading an excel files :
dfEx=pd.read_excel(fileExcel, engine='openpyxl')
There is a date column in Object format, and dfEx["Date"] gives me these results :
| id | date |
|---|---|
| 0 | 15/10/2022 10:44:59 |
| 1 | 15/10/2022 10:47:53 |
| 2 | 15/10/2022 10:49:50 |
| 3 | 15/10/2022 10:50:40 |
| 4 | 15/10/2022 10:54:05 |
| ... | |
| 174 | 2022-10-16 00:00:00 |
| 175 | 2022-10-16 00:00:00 |
| 176 | 2022-10-16 00:00:00 |
| 177 | 2022-10-16 00:00:00 |
| 178 | 2022-10-16 00:00:00 |
I don't get why I have the format change between the beginning and the end, as in the Excel file the separator character is always / for year/month/day
The syntax I have in the Excel file is :
15/10/2022 11:13:64
for the first and
15-10-2022
for the rest
So when I use the datetime function it doesn't work :
dfEx['Date'] = pd.to_datetime(dfEx['Date'], format='%d/%m/%Y %H:%M:%S', exact=False)
ValueError: time data '2022-10-15 00:00:00' does not match format '%d/%m/%Y %H:%M:%S' (search)
strand convert it in a second step.