繪製雞群位置
現在你要建立一個散佈圖,顯示納許維爾的雞都在哪裡!
本練習屬於課程
在 Python 視覺化地理空間資料
練習說明
- 雞隻資料集的路徑已存於變數
chickens_path。使用 pandas 的read_csv函式將其載入為名為chickens的 DataFrame。 - 使用
.head()函式檢視前幾列。 - 接著在
plt.scatter()中加入 x 和 y 參數來繪製納許維爾雞群的位置。使用預設的標記與顏色設定即可。 - 使用
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()