<jupyter_start><jupyter_text>Simpson's ParadoxUse `admission_data.csv` for this exercise.<jupyter_code>import pandas as pd
# Load and view first few lines of dataset
admits = pd.read_csv("admission_data.csv")
admits.head()<jupyter_output><empty_output><jupyter_text>Proportion and admission rate for each gender<jupyter_code>print (len(admits[admits['gender']=='female']))
print (admits.shape[0])
# Proportion of students that are female
(len(admits[admits['gender']=='female']))/admits.shape[0]
# Proportion of students that are male
(len(admits[admits['gender']=='male']))/admits.shape[0]
# Admission rate for females
len(admits[(admits['gender']=='female') & (admits['admitted'])])/(len(admits[admits['gender']=='female']))
# Admission rate for males
len(admits[(admits['gender']=='male') & (admits['admitted'])])/(len(admits[admits['gender']=='male']))<jupyter_output><empty_output><jupyter_text>Proportion and admission rate for physics majors of each gender<jupyter_code># What proportion of female students are majoring in physics?
fem_phys_rate = admits.query("gender == 'female' & major == 'Physics'").count()/ \
    (admits.query("gender == 'female'").count())
print (fem_phys_rate)
# What proportion of male students are majoring in physics?
fem_phys_rate = admits.query("gender == 'male' & major == 'Physics'").count()/ \
    (admits.query("gender == 'male'").count())
print (fem_phys_rate)
# Admission rate for female physics majors
len(admits[(admits["gender"]=='female') & (admits["major"] == 'Physics') & admits["admitted"]]) / len(admits[(admits["gender"]=='female') & (admits["major"] == 'Physics')])
# Admission rate for male physics majors
len(admits[(admits["gender"]=='male') & (admits["major"] == 'Physics') & admits["admitted"]]) / len(admits[(admits["gender"]=='male') & (admits["major"] == 'Physics')])<jupyter_output><empty_output><jupyter_text>Proportion and admission rate for chemistry majors of each gender<jupyter_code># What proportion of female students are majoring in chemistry?
len(admits[(admits['gender']=='female') & (admits['major'] == 'Chemistry')]) / len(admits[admits['gender']=='female'])
# What proportion of male students are majoring in chemistry?
len(admits[(admits['gender']=='male') & (admits['major'] == 'Chemistry')]) / len(admits[admits['gender']=='male'])
# Admission rate for female chemistry majors
len(admits[(admits['gender']=='female') & (admits['major'] == 'Chemistry') & admits['admitted']]) / len(admits[(admits['gender']=='female') & (admits['major'] == 'Chemistry')])
# Admission rate for male chemistry majors
len(admits[(admits['gender']=='male') & (admits['major'] == 'Chemistry') & admits['admitted']]) / len(admits[(admits['gender']=='male') & (admits['major'] == 'Chemistry')])<jupyter_output><empty_output><jupyter_text>Admission rate for each major<jupyter_code># Admission rate for physics majors
len(admits[(admits['major'] == 'Physics') & admits['admitted']]) / len(admits[(admits['major'] == 'Physics')])
# Admission rate for chemistry majors
len(admits[(admits['major'] == 'Chemistry') & admits['admitted']]) / len(admits[(admits['major'] == 'Chemistry')])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20322376738305942, 'fraction_numerical': 0.0009481668773704172, 'mean_word_length': 9.015822784810126, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '428836', 'license': 'MIT', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1023, 'n_words': 211, 'path': 'lessons/Other/simpsons_paradox.ipynb', 'repo_name': 'rabadzhiyski/Data_Science_Udacity', 'size': '3164'}