Complete the code to import the date formatter from matplotlib.dates.
from matplotlib.dates import [1]
The DateFormatter class is used to format dates on matplotlib axes.
Complete the code to set the x-axis major formatter to display dates as 'Year-Month'.
ax.xaxis.set_major_formatter([1]('%Y-%m'))
DateFormatter formats dates according to the given string pattern.
Fix the error in the code to import matplotlib.dates as mdates.
import matplotlib.[1] as mdates
The correct submodule name is dates in matplotlib.
Fill both blanks to create a dictionary comprehension that maps dates to formatted strings using DateFormatter.
formatted_dates = {date: [1]('%Y-%m-%d').format_data(date) for date in dates if date [2] datetime.date(2023, 1, 1)}Use DateFormatter to format dates and the '>' operator to filter dates after Jan 1, 2023.
Fill all three blanks to create a dictionary comprehension that maps date strings to datetime objects parsed with strptime.
date_dict = [1]([2]: datetime.datetime.strptime([2], '%Y-%m-%d') for [2] in date_strings)
Use dict to create the dictionary, and date_str as the loop variable for date strings.