Session Ready
Exercise

pandas line plots

In the previous chapter, you saw that the .plot() method will place the Index values on the x-axis by default. In this exercise, you'll practice making line plots with specific columns on the x and y axes.

You will work with a dataset consisting of monthly stock prices in 2015 for AAPL, GOOG, and IBM. The stock prices were obtained from Yahoo Finance. Your job is to plot the 'Month' column on the x-axis and the AAPL and IBM prices on the y-axis using a list of column names.

All necessary modules have been imported for you, and the DataFrame is available in the workspace as df. Explore it using methods such as .head(), .info(), and .describe() to see the column names.

Instructions
100 XP
  • Create a list of y-axis column names called y_columns consisting of 'AAPL' and 'IBM'.
  • Generate a line plot with x='Month' and y=y_columns as inputs.
  • Give the plot a title of 'Monthly stock prices'.
  • Specify the y-axis label.
  • Display the plot.