開始使用免費開始

分組叢集

2016 年持續進行中的一項調查,旨在衡量科技職場對心理健康的態度,並檢視科技從業人員出現心理健康狀況的頻率。這是一份針對科技產業參與者的線上調查。

資料集 mh_survey 包含受訪者的 gender、其居住的美國州別 US_state_live,以及他們是否曾透過雇主尋求心理健康治療 sought_treatment

pandasmatplotlib.pylot 已分別以 pdplt 幫你載入。

本練習屬於課程

使用 Python 分析問卷資料

檢視課程

練習說明

  • US_state_live 將母體分成叢集,並計算受訪者人數。
  • 繪製依 US_state_live 分組的受訪者人數長條圖。

動手互動練習

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

# Group population into clusters and calculate respondents
groups = mh_survey.____(____)[____].____.reset_index()
groups.columns = ['US_state_live','count']

# Plot a bar graph of number of respondents by US_state_live
groups.____.____(____,y='count')
plt.show()
編輯並執行程式碼