開始使用免費開始

在多邊形內彙總點資料

既然你已經把 artneighborhoods 做了空間連接,你就可以對資料進行分組、彙總與排序,找出哪個鄰里有最多的公共藝術。你可以計算作品標題的數量,來看每個鄰里各有多少件作品。

本練習屬於課程

在 Python 視覺化地理空間資料

檢視課程

練習說明

  • neighborhood_art 只取出 nametitle,然後依每個鄰里的名稱(name)分組。將結果存成 neighborhood_art_grouped
  • neighborhood_art_grouped 進行彙總,查看每個多邊形內有多少件作品。使用 .agg('count') 來取得各鄰里的作品數量,並用 .sort_values() 排序,by 設為 titleascending 設為 False。列印結果。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Get name and title from neighborhood_art and group by name
neighborhood_art_grouped = neighborhood_art[['name', 'title']].groupby(____)

# Aggregate the grouped data and count the artworks within each polygon
print(____.agg('count').sort_values(by = ____, ascending = False))
編輯並執行程式碼