<jupyter_start><jupyter_text>Load data<jupyter_code>df = pd.read_csv("data/adult.csv")
df.info()
df.head(5)<jupyter_output><empty_output><jupyter_text>1. How many men and women (sex feature) are represented in this dataset?<jupyter_code>df['gender'].value_counts()<jupyter_output><empty_output><jupyter_text>2. What is the average age (age feature) of women?<jupyter_code>df[df['gender'] == 'Female']['age'].mean()<jupyter_output><empty_output><jupyter_text>3. What is the percentage of German citizens (native-country feature)?<jupyter_code>df['native-country'].value_counts(normalize=True)<jupyter_output><empty_output><jupyter_text>4-5. What are the mean and standard deviation of age for those who earn more than 50K per year (salary feature) and those who earn less than 50K per year?<jupyter_code>df.groupby(by=['income'])['age'].describe()<jupyter_output><empty_output><jupyter_text>6. Is it true that people who earn more than 50K have at least high school education? (education – Bachelors, Prof-school, Assoc-acdm, Assoc-voc, Masters or Doctorate feature)<jupyter_code>df[df['income'] =='>50K']['education'].value_counts()<jupyter_output><empty_output><jupyter_text>7. Display age statistics for each race (race feature) and each gender (sex feature). Use groupby() and describe(). Find the maximum age of men of Amer-Indian-Eskimo race<jupyter_code>df.groupby(by=['race', 'gender'])['age'].describe()<jupyter_output><empty_output><jupyter_text>8. Among whom is the proportion of those who earn a lot (>50K) greater: married or single men (marital-status feature)? Consider as married those who have a marital-status starting with Married (Married-civ-spouse, Married-spouse-absent or Married-AF-spouse), the rest are considered bachelors.<jupyter_code>df['marital-status'].unique()
d = {'Married-civ-spouse' : 'married',
    'Married-spouse-absent' : 'married',
    'Married-AF-spouse' : 'married',
    'Never-married' : 'single',
    'Widowed' : 'single',
    'Divorced' : 'single', 
    'Separated' : 'single'}
df['committed-update'] = df['marital-status'].map(d)
df.groupby(by=['committed-update'])['income'].value_counts()<jupyter_output><empty_output><jupyter_text>9. What is the maximum number of hours a person works per week (hours-per-week feature)? How many people work such a number of hours, and what is the percentage of those who earn a lot (>50K) among them?<jupyter_code>df['hours-per-week'].max()
len(df[df['hours-per-week'] == 99])
df[df['hours-per-week'] == 99]['income'].value_counts(normalize=True)<jupyter_output><empty_output><jupyter_text>10. Count the average time of work (hours-per-week) for those who earn a little and a lot (salary) for each country (native-country). What will these be for Japan?<jupyter_code>df.groupby(by=['native-country','income'])['hours-per-week'].describe()
df[df['native-country'] == 'Japan'].groupby(by=['income'])['hours-per-week'].describe()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1510204081632653, 'fraction_numerical': 0.009523809523809525, 'mean_word_length': 7.057534246575343, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 44, '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': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '558159', 'license': 'Apache-2.0', 'n_tokens_mistral': 1040, 'n_tokens_neox': 985, 'n_words': 246, 'path': 'week1/EDA-on-adult-dataset.ipynb', 'repo_name': 'keerthana-ceg/mlcourse.ai', 'size': '2940'}