計算標準化指標
現在你要將各議會選區核發的建築許可數,除以該選區的面積,得到標準化後的許可值。首先,先確認 districts_and_permits 仍然是 GeoDataFrame。
本練習屬於課程
在 Python 視覺化地理空間資料
練習說明
- 印出
districts_and_permits的type()。 - 幫
districts_and_permits再新增一個欄位。使用 lambda 運算式與pandas的apply()方法,將各議會選區的建築許可核發數除以該選區的面積,得到標準化後的許可值。 - 印出
districts_and_permits的前五列。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Print the type of districts_and_permits
print(____(____))
# Create permit_density column in districts_and_permits
districts_and_permits['permit_density'] = districts_and_permits.apply(lambda row: row._____ / row._____, axis = 1)
# Print the head of districts_and_permits
print(____.____())