Calculate number of shares outstanding
The next step towards building a value-weighted index is to calculate the number of shares for each index component.
The number of shares will allow you to calculate the total market capitalization for each component given the historical price series in the next exercise.
Diese Übung ist Teil des Kurses
Manipulating Time Series Data in Python
Anleitung zur Übung
We have already imported pandas as pd, tickers and listings as in the previous exercises.
- Inspect
listingsand printtickers. - Use
.loc[]with the list oftickersto select the index components and the columns'Market Capitalization'and'Last Sale'; assign this tocomponents. - Print the first five rows of
components. - Create
no_sharesby dividingMarket Capitalizationby'Last Sale'. - Print
no_sharesin descending order.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Inspect listings and print tickers
print(____)
print(____)
# Select components and relevant columns from listings
components = ____
# Print the first rows of components
print(____)
# Calculate the number of shares here
no_shares = ____
# Print the sorted no_shares
print(____)