LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Analyzing Survey Data in Python

Kurs anzeigen

Anleitung zur Übung

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

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# 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()
Code bearbeiten und ausführen