ニワトリの位置をプロットする
Nashville のニワトリがどこにいるかを示す散布図を作成しましょう。
この演習はコースの一部です
Pythonで可視化する地理空間データ
演習の手順
- ニワトリのデータセットへのパスは変数
chickens_pathにあります。pandas のread_csv関数を使って読み込み、chickensという DataFrame に格納します。 .head()関数で先頭の数行を確認します。- 次に、
plt.scatter()に x と y の引数を追加して、Nashville のニワトリの位置をプロットします。マーカーと色はデフォルトのままで構いません。 plt.show()を使ってプロットを表示します。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Import pandas and matplotlib.pyplot using their customary aliases
import pandas as pd
import matplotlib.pyplot as plt
# Load the dataset
chickens = pd.____(chickens_path)
# Look at the first few rows of the chickens DataFrame
print(chickens.____())
# Plot the locations of all Nashville chicken permits
plt.scatter(x = chickens.____, y = chickens.____)
# Show the plot
plt.show()