Get startedGet started for free

Cluster sampling analysis

You and a group of psychologists are interested in analyzing employee mental health. Your research includes a survey that aims to measure attitudes towards mental health in the tech workplace, and examine the frequency of mental health conditions among tech workers.

The dataset, mh_survey, includes the gender of the respondent, the US state they live in,US_state_live, and whether they have sought treatment for their mental health through their employer, sought_treatment.

You will create a pie chart to analyze the likelihood of a tech worker seeking treatment regarding their mental health in the US, sought_treatment. A random list of 10 state clusters, random_cluster, has bee uploaded for you.

Pandas and numpy as been uploaded as pd and np.

This exercise is part of the course

Analyzing Survey Data in Python

View Course

Exercise instructions

  • Subset dataset to include only states in random_clusters.
  • Create a pie chart of the sought_treatment column.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# 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()
Edit and Run Code