Complete the code to extract the year from a datetime column in pandas.
df['year'] = df['date_column'].dt.[1]
The dt.year attribute extracts the year part from a datetime column in pandas.
Complete the code to extract the weekday name from a datetime column in pandas.
df['weekday'] = df['date_column'].dt.[1]()
The dt.day_name() method returns the weekday name (like Monday, Tuesday) from a datetime column.
Fix the error in the code to extract the hour from a datetime column.
df['hour'] = df['date_column'].[1].hour
The .dt accessor is needed to access datetime properties like hour in pandas Series.
Fill both blanks to create a new column with the month and day extracted from a datetime column.
df['month_day'] = df['date_column'].dt.[1].astype(str) + '-' + df['date_column'].dt.[2].astype(str)
Extracting month and day and converting them to strings allows combining them into a 'month-day' format.
Fill all three blanks to create a dictionary comprehension that maps each date to its weekday number if the hour is greater than 12.
result = {date: date.[1] for date in df['date_column'] if date.[2] [3] 12}The dictionary comprehension extracts the weekday number for dates where the hour is greater than 12.