按惯用手加权抽样
您是大学研究团队的一员,正在开展有关左撇子的研究。您通过学校的社交媒体平台发放问卷,询问参与者在某些任务中使用哪只手。问卷收集了受访者的性别 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()