Complete the code to extract the year from the 'date' column in the DataFrame.
df['year'] = df['date'].dt.[1]
dt accessor.The dt.year attribute extracts the year component from datetime values.
Complete the code to extract the month from the 'date' column in the DataFrame.
df['month'] = df['date'].dt.[1]
dt accessor.The dt.month attribute extracts the month component from datetime values.
Fix the error in the code to extract the day from the 'date' column.
df['day'] = df['date'].[1]
date.day which is invalid for pandas Series.dt.day() as a function.To extract the day, use the dt.day attribute. It must be accessed via dt without parentheses.
Fill both blanks to create a dictionary with years as keys and months as values from the 'date' column.
date_dict = {df['date'].dt.[1][i]: df['date'].dt.[2][i] for i in range(len(df))}This dictionary comprehension uses dt.year for keys and dt.month for values.
Fill all three blanks to create a list of tuples (year, month, day) from the 'date' column.
date_tuples = [(df['date'].dt.[1][i], df['date'].dt.[2][i], df['date'].dt.[3][i]) for i in range(len(df))]
This list comprehension extracts year, month, and day components to form tuples.