DateTimeIndex の作成
DatetimeIndex があると、さまざまな点で便利です。ブラケット表記で任意の期間を選べますし、コード1行で折れ線グラフを作成できます。
Date が datetime 列として読み込まれている apple 株価データセットで、これらの操作を練習しましょう。
この演習はコースの一部です
Anomaly Detection in Python
演習の手順
appleDataFrame のインデックスとしてDate列を設定してください。- 2008年7月初日から2013年12月9日までの Apple 株の
Open列を、赤色の折れ線グラフで作成してください。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Set the Date column as a DatetimeIndex
apple.____(____)
# Plot the opening prices for the instructed range
apple____
plt.title("Opening prices of Apple stocks from the beginning of July of 2008 to December of 2013.")
plt.show()