Skip to content

Glossary: pandas Basics

strftime

Also written: .dt.strftime(), %Y-%m, format codes

Formats dates as text using `%` codes (`%Y` year, `%m` month, `%d` day). `.dt.strftime("%Y-%m")` gives labels like `2026-09` for grouping by month, and the same codes tell `to_datetime` how to read text.

Where the book teaches it

Related terms

to_datetimeAccessor