Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit 9dfd7f34 by Liwen Huang

parent ca0977cb
 { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 2¶\n", "It would be interesting to see if there is any evidence of a link between vaccine effectiveness and sex of the child. Calculate the ratio of the number of children who contracted chickenpox but were vaccinated against it (at least one varicella dose) versus those who were vaccinated but did not contract chicken pox. Return results by sex.\n", "\n", "This function should return a dictionary in the form of (use the correct numbers):\n", "\n", " {\"male\":0.2,\n", " \"female\":0.4}\n", "Note: To aid in verification, the chickenpox_by_sex()['female'] value the autograder is looking for starts with the digits 0.00779." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
1128521128522NaN235.91695610312017NaN21...NaNNaNNaNNaNNaNNaNNaNNaN
21074110742NaN957.35384010682017NaN21...NaNNaNNaNNaNNaNNaNNaNNaN
3220011220012NaN189.61129910502017NaN23...NaNNaNNaNNaNNaNNaNNaNNaN
48613186131675.430817333.44741810402017NaN21...NaNNaNNaNNaNNaNNaN1.02.0
5227141227141482.617748278.76806310082017NaN21...NaNNaNNaNNaNNaNNaN2.01.0
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "

5 rows × 453 columns

\n", "" ], "text/plain": [ " SEQNUMC SEQNUMHH PDAT PROVWT_D RDDWT_D STRATUM YEAR AGECPOXR \\\n", "1 128521 12852 2 NaN 235.916956 1031 2017 NaN \n", "2 10741 1074 2 NaN 957.353840 1068 2017 NaN \n", "3 220011 22001 2 NaN 189.611299 1050 2017 NaN \n", "4 86131 8613 1 675.430817 333.447418 1040 2017 NaN \n", "5 227141 22714 1 482.617748 278.768063 1008 2017 NaN \n", "\n", " HAD_CPOX AGEGRP ... XVRCTY2 XVRCTY3 XVRCTY4 XVRCTY5 XVRCTY6 \\\n", "1 2 1 ... NaN NaN NaN \n", "2 2 1 ... NaN NaN NaN \n", "3 2 3 ... NaN NaN NaN \n", "4 2 1 ... NaN NaN NaN \n", "5 2 1 ... NaN NaN NaN \n", "\n", " XVRCTY7 XVRCTY8 XVRCTY9 INS_STAT2_I INS_BREAK_I \n", "1 NaN NaN NaN NaN NaN \n", "2 NaN NaN NaN NaN NaN \n", "3 NaN NaN NaN NaN NaN \n", "4 NaN NaN NaN 1.0 2.0 \n", "5 NaN NaN NaN 2.0 1.0 \n", "\n", "[5 rows x 453 columns]" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import numpy as np\n", "import pandas as pd\n", "\n", "df = pd.read_csv('datasets/NISPUF17.csv', index_col=0)\n", "\n", "df.head()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
112NaN
212NaN
322NaN
4221.0
5220.0
\n", "\n", "\n", "