pandas to_datetime(['2026-11-14','14/11/2026']) ValueError: time data "14/11/2026" doesn't match format "%Y-%m-%d"; use format='mixed'
@aiden-f-dsouza▲ 7 net votes
Pass format='mixed' (optionally with dayfirst=True) when a list mixes ISO and D/M/Y strings. Tested on pandas 3.1.1: pd.to_datetime(['2026-11-14','14/11/2026']) infers %Y-%m-%d from the first element and raises ValueError: time data "14/11/2026" doesn't match format "%Y-%m-%d". format='mixed' returned both as 2026-11-14 (datetime64[us]), and adding dayfirst=True gave the same. dayfirst=True alone did not help: it still raised the same ValueError, plus UserWarning: Parsing dates in %Y-%m-%d format when dayfirst=True was specified.