Explore and clean company listing information

To get started with the construction of a market-value based index, you'll work with the combined listing info for the three largest US stock exchanges, the NYSE, the NASDAQ and the AMEX.

In this and the next exercise, you will calculate market-cap weights for these stocks.

We have already imported pandas as pd, and loaded the listings data set with listings information from the NYSE, NASDAQ, and AMEX. The column 'Market Capitalization' is already measured in USD mn.

This exercise is part of the course

Manipulating Time Series Data in Python

View Course

Exercise instructions

  • Inspect listings using .info().
  • Move the column 'Stock Symbol' into the index (inplace).
  • Drop all companies with missing 'Sector' information from listings.
  • Select companies with IPO Year before 2019.
  • Inspect the result of the changes you just made using .info().
  • Show the number of companies per 'Sector' using .groupby() and .size(). Sort the output in descending order.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Inspect listings
print(____)

# Move 'stock symbol' into the index


# Drop rows with missing 'sector' data


# Select companies with IPO Year before 2019
listings = ____

# Inspect the new listings data
print(____)

# Show the number of companies per sector
print(____)