Recall & Review
beginner
What Python library is commonly used to work with dates and times in data analysis?
The pandas library is commonly used because it has powerful tools to handle dates and times easily.
Click to reveal answer
beginner
How do you extract the year from a pandas datetime column named
date?Use
df['date'].dt.year to get the year part from each date in the column.Click to reveal answer
beginner
What does
df['date'].dt.month return?It returns the month number (1 for January, 2 for February, etc.) for each date in the
date column.Click to reveal answer
beginner
How can you extract the day of the month from a pandas datetime column?
Use
df['date'].dt.day to get the day number (1 to 31) from each date.Click to reveal answer
beginner
Why is it useful to extract year, month, and day from a datetime column?
Extracting these parts helps analyze data by time periods, like grouping sales by year or finding trends by month.
Click to reveal answer
Which pandas attribute extracts the month from a datetime column?
✗ Incorrect
The
.dt.month attribute extracts the month number from datetime values.What type of data must a pandas column be to use
.dt.year?✗ Incorrect
The column must be of datetime type to use
.dt.year.If you want to get the day of the month from a datetime column, which code is correct?
✗ Incorrect
df['date'].dt.day extracts the day number from each date.What does
df['date'].dt.year return?✗ Incorrect
It returns the year part of each date.
Why might you extract date parts like year or month from a datetime column?
✗ Incorrect
Extracting date parts helps analyze and group data by time periods.
Explain how to extract the year, month, and day from a pandas datetime column.
Think about the pandas datetime accessor .dt and its attributes.
You got /4 concepts.
Describe why extracting date components is helpful in data analysis.
Consider how time-based patterns are found in data.
You got /3 concepts.