開始使用免費開始

每個群組一個視覺化

在進行一個資料探索專案時,你被要求依 "Period of stay" 與星期幾("Review weekday")來視覺化飯店評論的數量。這個視覺化的目標是找出在每個四種停留期間中,星期幾的評論最多。reviews 資料集已經替你預先載入,seaborn(作為 sns)與 matplotlib.pyplot(作為 plt)也都可用。

本練習屬於課程

在 Python 中處理類別資料

檢視課程

練習說明

  • 使用 "count" 作為圖表類型建立 catplot()
  • "Review weekday" 統計評論數量。
  • 為每個 "Period of stay" 建立個別的圖。
  • 每 2 張圖就換行顯示。

動手互動練習

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

# 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()
編輯並執行程式碼