Tips and Tricks

How to Auto-Detect the Date/Datetime Columns and Set Their Datatype When Reading a CSV File in Pandas

When read_csv( ) reads e.g. “2021-03-04” and “2021-03-04 21:37:01.123” as mere “object” datatypes, often you can simply auto-convert them all at once to true datetime datatypes as shown here:

David B Rosen (PhD)
Towards Data Science
5 min readAug 16, 2021

--

--

--