0

I'm working with a data where there are multiple date columns. I need to drop columns where there are NA values, and for that I need to first convert the column type to date.time like in the code below:

df['column_name'] = df['column_name'].astype('datetime64[ns]')

However, as you can see the second date column is different. It is not 2023-01-2025 but January 25, 2023. Because of this inconsistency, I cannot convert the column type into datetime. Its dtype is still "object". How can I harmonize those dates which are completely in a different format?

139190  109596-85122015396  2023-01-25 20:08:00 January 25, 2023, 8:08 PM
40426   109596-85122015396  2023-01-25 20:08:38 2023-01-25T20:08:38Z

I tried editing using Handling multiple datetime formats with pd.to_datetime

However, I get NaT in the column when I try to convert.

139190  109596-85122015396  2023-01-25 20:08:00 NaT
40426   109596-85122015396  2023-01-25 20:08:38 NaT

Additionally, my problem is different as I have a problem with the time as well. In the problematic column, the time is in AM/PM where as in the other one it is 24h system

0 Answers0