Skip to content
C

Problem 2: Extract Features from a Date Column

Easypython

Problem Description

Write a Python program that extracts the day-of-week and an "is_weekend" flag from a date column in a DataFrame.

Input

A DataFrame with a date column.

Output

The DataFrame with new "dayofweek" and "is_weekend" columns.

Constraints

  • Dates should be in a format Pandas can parse.

Example Input

text
{"date": ["2024-01-06", "2024-01-08"]}

Example Output

text
date day_of_week is_weekend 0 2024-01-06 5 1 1 2024-01-08 0 0

Concepts Covered

pd.to_datetime(), .dt.dayofweek, .isin().

Input (stdin)

Output

Run your code to see output here...