以慣用手為主題的加權抽樣
你是大學研究團隊的一員,準備進行一項關於左撇子的研究。你透過學校的社群媒體發放問卷,詢問受試者在特定任務中慣用哪一隻手。問卷蒐集受試者的性別 Gender、年齡 Age,以及慣用手 Left - right handed。
資料集、pandas 與 matplotlib.pyplot 已分別以上傳為 hand_survey、pd 和 plt。
本練習屬於課程
使用 Python 分析問卷資料
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Groupby Gender and Handedness
hand_survey = hand_survey.groupby(
[____])[
____].____.reset_index()
hand_survey.columns = ['Gender','Handedness','Respondents']
# Create new column that calculates the percentage of each respondent type
hand_survey['% total respondents'] = ____*100./____.sum()