Skip to content
Discussion options

You must be logged in to vote

Preprocessing is the expected approach, but the reason all three rows come back invalid is worth spelling out, because it isn't the reason it looks like.

cast=True runs the frame through match_to_schema(..., casting="lenient"), and lenient casting is literally this, from _match_to_schema.py:

def _cast_if_required(expr, current_dtype, column, *, strict=True):
    if column.validate_dtype(current_dtype):
        return expr
    return expr.cast(column.dtype, strict=strict)

So what runs is pl.col("value").cast(pl.Datetime, strict=False). That's cast, not str.to_datetime, and in polars those aren't the same thing at all. cast is not a date parser. Anything it can't turn into a Datetime become…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@adrianstone
Comment options

Answer selected by adrianstone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants