始める無料で始める

中国、インド、米国のインフレ動向

最後に、seaborn パッケージには、カテゴリ変数の水準の分布を可視化するための関数が用意されています。

次の2つの演習では、FRED のデータを使って、過去50年以上にわたる中国、インド、米国のインフレ率の推移を確認します。さきほど学んだ関数を使う前に、生データに慣れておきましょう。pandaspdmatplotlib.pyplotpltseabornsns としてインポート済みです。FRED のインフレデータは inflation としてワークスペースに用意されています。

この演習はコースの一部です

Pythonでの金融データのインポートと管理

コースを見る

演習の手順

  • .info() を使って inflation を確認します。
  • inflation'Country' でグループ化し、inflation_by_country に代入します。
  • for ループで、inflation_by_country から返される countrydata のペアを反復処理します。各イテレーションで、data に対して .plot() を使い、titlecountry に設定して過去の時系列を表示します。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

# Inspect the inflation data
inflation.____()

# Create inflation_by_country
inflation_by_country = inflation.____(____)

# Iterate over inflation_by_country and plot the inflation time series per country
for country, data in inflation_by_country:
    # Plot the data
    data.____(____=____)
    # Show the plot
    plt.show()
コードを編集して実行