分組叢集
2016 年持續進行中的一項調查,旨在衡量科技職場對心理健康的態度,並檢視科技從業人員出現心理健康狀況的頻率。這是一份針對科技產業參與者的線上調查。
資料集 mh_survey 包含受訪者的 gender、其居住的美國州別 US_state_live,以及他們是否曾透過雇主尋求心理健康治療 sought_treatment。
pandas 與 matplotlib.pylot 已分別以 pd 與 plt 幫你載入。
本練習屬於課程
使用 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()