Reading a CSV into Python Pandas, and parse_dates doesn’t recognize the format? Pass the date_format keyword arg: All strftime codes work!
If you’re like me, then you’ve lately been exploring agentic coding, having AI write code on your behalf. What will be the impact on our work developing software? On hiring? On training? From what I can tell, the question isn’t whether we’ll be using agentic coding, but how we do so. Knowing how AI writes…
Reading a CSV into Python Pandas, and want a column to be treated as datetime values? Use parse_dates: Bonus: The PyArrow engine often (not always) parses columns that look like dates.
Want to take a Python Pandas series of strings, and get datetime values? Use pd.to_datetime: Notice: It’s not a method! It’s a top-level pd function. Specify a non-standard “format” with a strftime string:
If a Python string contains an ISO-formatted date, skip strptime and use datetime.fromisoformat:
Having a tough time remembering Python strptime vs. strftime? – The “p” (strptime) is for parsing, getting a datetime from a string– The “f” (strftime) is for formatting, getting a string from a datetime For help remembering the format codes, turn to https://www.strfti.me/ !
Want to parse a Python string into a datetime? Use strptime, passing (a) the string and (b) the date format specification: Both return datetime.datetime(2026, 4, 1, 0, 0)
Want to format a Python datetime as a string? Use strftime:
Want a Python datetime with a timezone? Use the “zoneinfo” module: Then pass it to the “tzinfo” keyword arg:
Want a Python datetime? Just invoke datetime.datetime: Omitted time units are 0: