Extracting year, month, day from dates using pandas
📖 Scenario: You work in a company that tracks employee joining dates. You have a list of joining dates and want to analyze the year, month, and day separately to find trends.
🎯 Goal: Build a pandas DataFrame with joining dates, then extract the year, month, and day into new columns.
📋 What You'll Learn
Create a pandas DataFrame with a column named
joining_date containing specific dates.Create a variable called
date_column that holds the string 'joining_date'.Use pandas datetime accessor to extract year, month, and day from the
joining_date column into new columns named year, month, and day.Print the final DataFrame to show the extracted columns.
💡 Why This Matters
🌍 Real World
Extracting year, month, and day from dates helps businesses analyze trends over time, like employee joining patterns or sales by month.
💼 Career
Data analysts and data scientists often need to break down dates to perform time-based analysis and reporting.
Progress0 / 4 steps