그룹별로 하나의 시각화
데이터 탐색 프로젝트를 진행하면서, 호텔 리뷰 수를 "Period of stay"와 요일인 "Review weekday"별로 시각화하라는 요청을 받았어요. 이 시각화의 목표는 네 가지 체류 기간 각각에서 어떤 요일에 리뷰가 가장 많은지 확인하는 거예요. reviews 데이터셋은 미리 로드되어 있으며, seaborn은 sns로, matplotlib.pyplot은 plt로 임포트되어 있어요.
이 연습은 강의의 일부입니다
Python으로 범주형 데이터 다루기
연습 안내
"count"를 그래프 유형으로 사용해catplot()을 만드세요."Review weekday"별 리뷰 수를 집계하세요.- 각
"Period of stay"에 대해 개별 플롯을 만드세요. - 그래픽 두 개마다 줄바꿈되도록 플롯을 감싸세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Create a catplot for each "Period of stay" broken down by "Review weekday"
ax = sns.catplot(
# Make sure Review weekday is along the x-axis
____,
# Specify Period of stay as the column to create individual graphics for
____,
# Specify that a count plot should be created
____,
# Wrap the plots after every 2nd graphic.
____,
data=reviews
)
plt.show()