発行株式数(shares outstanding)を計算する
時価総額加重指数を作成する次のステップは、各インデックス構成銘柄の発行株式数を計算することです。
発行株式数がわかると、次の演習で使う過去の株価系列を用いて、各構成銘柄の時価総額を計算できるようになります。
この演習はコースの一部です
Pythonでの時系列データ操作
演習の手順
すでに pandas は pd として、tickers と listings も前の演習と同様にインポート済みです。
listingsを確認し、tickersを出力します。.loc[]とtickersのリストを使ってインデックス構成銘柄を選択し、列は'Market Capitalization'と'Last Sale'を指定します。結果をcomponentsに代入します。componentsの先頭5行を表示します。'Market Capitalization'を'Last Sale'で割ってno_sharesを作成します。no_sharesを降順で表示します。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# 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(____)