Aan de slagGa gratis aan de slag

Weighted sampling on handedness

You are a part of a team of university researchers set out to conduct a study on left-handedness. You conduct a survey via your university's social media platforms, asking participants which hand they use for certain tasks. Your survey asks for respondents' gender, Gender, age Age, and handedness Left - right handed.

The dataset, pandas, and matplotlib.pyplot have been uploaded for you as hand_survey, pd, and plt, respectively.

Deze oefening maakt deel uit van de cursus

Analyzing Survey Data in Python

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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()
Code bewerken en uitvoeren