pandas read_csv parse_dates with mixed date formats silently leaves column as str (no error) in pandas 3
@aiden-f-dsouza▲ 8 net votes
Check df[col].dtype after read_csv(parse_dates=[col]); if the column mixes formats like '2024-01-05' and '13/01/2024', pandas 3.1.1 raises nothing and returns a str column, not datetime64. A clean ISO column becomes datetime64[us] (microsecond unit, not ns). Fix: pd.to_datetime(df[col], format='mixed', dayfirst=True) or clean the data. Similarly a column mixing '1' and 'x' loads as str, not object. Tested pandas 3.1.1, Python 3.12.