1. Learn
  2. /
  3. Courses
  4. /
  5. Manipulating Time Series Data in Python

Connected

Exercise

Import index component price information

Now you'll use the stock symbols for the companies you selected in the last exercise to calculate returns for each company.

Instructions

100 XP

We have already imported pandas as pd and matplotlib.pyplot as plt for you. We have also made the variable tickers available to you, which contains the Stock Symbol for each index component as a list.

  • Print tickers to verify the content matches your result from the last exercise.
  • Use pd.read_csv() to import 'stock_prices.csv', parsing the 'Date' column and also setting the 'Date' column as index before assigning the result to stock_prices. Inspect the result using .info().
  • Calculate the price return for the index components by dividing the last row of stock_prices by the first, subtracting 1 and multiplying by 100. Assign the result to price_return.
  • Plot a horizontal bar chart of the sorted returns with the title Stock Price Returns.