Section 3. Chapter 4
single
Challenge: Dates & Times
Swipe to show menu
Task
Swipe to start coding
Implement the function parse_release_dates(df: pl.DataFrame) -> pl.DataFrame.
-
Use the
.with_columns()context to overwrite the existing column named exactly"Release date". -
Apply
.str.to_date()to the target column using the layout string format%b %d, %Y(which maps to formats like "Dec 10, 2020"). -
Pass
strict=Falseinside.to_date()to handle malformed dates defensively. -
Return the updated Polars DataFrame.
Solution
Everything was clear?
Thanks for your feedback!
Section 3. Chapter 4
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat