Extracting Day of Week and Hour from Timestamps
📖 Scenario: You work at a delivery company. You have a list of delivery times. You want to find out which day of the week and hour of the day most deliveries happen.
🎯 Goal: Create a pandas DataFrame with delivery timestamps. Then extract the day of the week and hour from these timestamps. Finally, display the new data.
📋 What You'll Learn
Create a pandas DataFrame called
df with a column 'delivery_time' containing the exact timestamps given.Create a variable called
time_column and set it to the string 'delivery_time'.Use pandas datetime properties to create two new columns in
df: 'day_of_week' and 'hour', extracted from time_column.Print the updated DataFrame
df.💡 Why This Matters
🌍 Real World
Delivery companies analyze delivery times to optimize routes and staffing. Extracting day and hour helps find busy times.
💼 Career
Data analysts and scientists often work with timestamps to find patterns in time-based data.
Progress0 / 4 steps