3. A Deep Dive into Matplotlib
Activity 3.01: Visualizing Stock Trends by Using a Line Plot
Solution:
Visualize a stock trend by using a line plot:
- Create an
Activity3.01.ipynb
Jupyter notebook in theChapter03/Activity3.01
folder to implement this activity. - Import the necessary modules and enable plotting within the Jupyter notebook:
# Import statements import matplotlib.pyplot as plt import numpy as np import pandas as pd %matplotlib inline
- Use pandas to read the datasets (
GOOGL_data.csv
,FB_data.csv
,AAPL_data.csv
,AMZN_data.csv
, andMSFT_data.csv
) located in theDatasets
folder. Theread_csv()
function reads a .csv file into a DataFrame:# load datasets google = pd.read_csv('../../Datasets/GOOGL_data.csv') facebook = pd.read_csv('../../Datasets/FB_data.csv') apple = pd.read_csv('../../Datasets/AAPL_data.csv') amazon = pd.read_csv('../../Datasets/AMZN_data.csv') microsoft = pd.read_csv('../../Datasets/MSFT_data.csv...