폴리곤 내 포인트 집계하기
art와 neighborhoods를 공간 조인했으니, 이제 데이터를 그룹화하고 집계한 뒤 정렬해서 어느 동네에 공공 예술이 가장 많은지 확인할 수 있어요. 작품 제목 수를 세면 각 동네에 작품이 몇 점 있는지 알 수 있습니다.
이 연습은 강의의 일부입니다
Python으로 지리공간 데이터 시각화하기
연습 안내
neighborhood_art에서name과title만 선택한 뒤, 동네 이름(name)으로 그룹화하세요. 이를neighborhood_art_grouped로 저장하세요.- 각 폴리곤 안에 작품이 몇 점 있는지 확인하도록
neighborhood_art_grouped를 집계하세요. 각 동네의 작품 수는.agg('count')를 사용해 구하고,.sort_values()로 결과를 정렬하되by를title로,ascending은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))