Polars Convert String to Date: What the Conversion Changes and When to Use It
How to convert string columns to dates in Polars with str.to_date and str.strptime, what changes in the stored data, how failures behave, and when to keep plain text.
Converting a string column to a date in Polars turns text such as "2025-03-04" into a typed Date value that the library can sort, filter, compare and do arithmetic on. This review explains what the conversion does to the data, where it can silently change meaning, and when keeping the original text is the safer choice. It is based on documented Polars behavior and general principles, not on measured benchmarks or test results, because none were supplied.
Is converting strings to dates the right move for your data?
For most analysis work, yes. The main benefit is that a Date column behaves like a date: ranges, month or year extraction, differences between days and chronological sorting all work correctly, while sorting text only works by accident when every value uses a fixed-width, year-first format such as ISO 8601.
The decisive tradeoff is interpretation. Parsing commits to one reading of each string. A value like "03/04/2025" is March 4 under the common US month-first convention and April 3 under day-first conventions. Polars applies whatever format you give it, or the one it infers, to the whole column, so an incorrect format can produce valid-looking but wrong dates instead of an error.
Keeping plain text is preferable when the source mixes regional conventions and you cannot tell which rows use which, when values are partial or approximate ("2025", "Q3 2025", "circa 1990"), when you must keep the exact original spelling for audit or legal reasons, or when the column will only be displayed and never computed on. A practical middle ground is to keep the original string column and add a parsed column beside it.
What the conversion actually changes
This is a change to stored data, not a change in presentation. After parsing, the column's data type is Date, and Polars stores each value internally as a count of days relative to the Unix epoch (1970-01-01). The original characters, including separators, leading zeros, month names and any surrounding text, are not kept in the new column. When the Date is printed or written out, Polars renders it in its own default representation, which is year-month-day, regardless of how the source string was written.
Formatting in the other direction is a separate step. Turning a Date back into a string with a chosen pattern produces new text; it does not restore the original input. If the source was "4 Mar 2025", converting to a Date and back with a year-first pattern yields "2025-03-04", not the original wording.
Date and Datetime are different targets. Date holds a calendar day only. Datetime adds a time of day with a chosen precision and an optional time zone. Parsing a string that contains a time into Date discards the time portion, so choose Datetime when hours, minutes or offsets matter.
The main parsing methods
Current Polars versions expose the conversion through the string namespace on an expression. The format argument uses strftime-style specifiers, such as %Y for a four-digit year, %m for a zero-padded month and %d for a zero-padded day.
import polars as pl
df = pl.DataFrame({"raw": ["2025-03-04", "2025-12-31"]})
# Explicit format: the clearest option
df = df.with_columns(
pl.col("raw").str.to_date(format="%Y-%m-%d").alias("date")
)
# Equivalent, more general form
df = df.with_columns(
pl.col("raw").str.strptime(pl.Date, format="%Y-%m-%d").alias("date2")
)
| Method | Target type | Typical use |
| str.to_date(format=...) | Date | Day-only values |
| str.to_datetime(format=...) | Datetime | Values with time or offset |
| str.strptime(dtype, format=...) | Date, Datetime or Time | One call for any temporal type |
| read_csv(..., try_parse_dates=True) | Inferred | Quick loading of well-formed files |
Parameter names have changed between Polars releases; older code may use fmt where newer versions expect format. Check the documentation for the version you have installed before copying older examples.
Choosing the format for US-style and mixed dates
If the format is omitted, Polars tries to infer it from the data. Inference is convenient for clean ISO-style input, but it cannot resolve the month-first versus day-first question on its own. For any slash- or dot-separated input, state the format explicitly.
# US month-first: 03/04/2025 -> March 4, 2025
pl.col("raw").str.to_date(format="%m/%d/%Y")
# Day-first: 03/04/2025 -> April 3, 2025
pl.col("raw").str.to_date(format="%d/%m/%Y")
# Month names: "Mar 4, 2025"
pl.col("raw").str.to_date(format="%b %d, %Y")
Watch two-digit years. The %y specifier maps two-digit years into a fixed century window rather than reading intent from the data, so historical or far-future values can land in the wrong century. Month-name parsing is built around English names; whether non-English month names are supported in your setup was not confirmed in the supplied evidence, so treat localized month names as something to test or normalize first.
How failures behave
By default parsing is strict: if any value does not match the format, the operation raises an error. That is usually what you want, because it surfaces bad rows instead of hiding them. Setting strict=False changes failures into null values, which keeps the pipeline running but can quietly lose data.
parsed = df.with_columns(
pl.col("raw").str.to_date(format="%m/%d/%Y", strict=False).alias("date")
)
# Rows that had text but failed to parse
failed = parsed.filter(pl.col("raw").is_not_null() & pl.col("date").is_null())
If you use non-strict parsing, compare the parsed column with the original as above so that failed conversions are counted and reviewed rather than discarded. The exact parameter, true by default, requires the whole string to match the format; setting it to false lets the pattern match a portion of a longer string, which helps with values like "Date: 2025-03-04" but also makes accidental matches more likely.
Will the result stay readable and usable when shared?
Inside Polars, a Date column remains a date through filtering, joins, lazy queries and grouping. Outside Polars, usability depends on the output format. Binary columnar formats such as Parquet keep the date type. Text formats such as CSV store dates as characters again, so the receiving tool has to parse them, and it may apply its own regional assumptions.
- Write dates in year-month-day form when sharing text files; it is the least ambiguous across regions.
- If the audience expects US month-first display, format a separate presentation column with dt.strftime("%m/%d/%Y") rather than overwriting the typed column.
- Keep the original string column when exact source wording must be preserved.
- Document the format used for parsing so others can reproduce the result.
Accessibility and search depend on the destination, not on Polars. How a screen reader announces "2025-03-04" versus "March 4, 2025", or how a spreadsheet or reporting tool interprets an exported date string, was not covered by the supplied evidence, and no destination was tested. Where people will read the values directly, a spelled-out month is generally less ambiguous than an all-numeric form, but confirm the behavior in the specific tool you plan to use.
Gaps in this review
- No performance measurements were supplied, so no claims are made about parsing speed or memory use.
- Support for localized month names and non-English formats was not confirmed.
- Behavior in specific downstream tools and assistive technologies was not tested.
- API details vary by Polars version; verify against your installed release.
Bottom line
Converting strings to dates in Polars is worth doing whenever you need to compute on dates, provided you pass an explicit format, keep strict parsing on or audit nulls when it is off, and retain the original text when its exact form matters. Leave the column as plain text when the source conventions are mixed or unknowable, or when the values are only for display.