叢集抽樣分析
你和一組心理學家想要分析員工的心理健康。你的研究包含一份問卷,目的在衡量科技職場對心理健康的態度,並檢視科技從業人員心理健康狀況的發生頻率。
資料集 mh_survey 包含受訪者的 gender,其居住的美國州別 US_state_live,以及他們是否透過雇主尋求心理健康相關治療 sought_treatment。
你將建立一個圓餅圖,分析美國科技從業人員尋求心理健康相關治療(sought_treatment)的可能性。
已為你上傳 10 個州別叢集的隨機清單 random_cluster。
已將 Pandas 和 numpy 以上傳為 pd 與 np。
本練習屬於課程
使用 Python 分析問卷資料
練習說明
- 將資料集子集化,只保留
random_clusters中的州別。 - 建立
sought_treatment欄位的圓餅圖。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Subset dataset to inlude only states in cluster_sample
cluster_sample = ____[mh_survey.US_state_live.____(____)]
# Create a pie chart of the sought_treament column
treatment_pie = cluster_sample.____.____(normalize=True)
treatment_pie.____.____()
plt.show()