<jupyter_start><jupyter_text><jupyter_code>import pandas as pd
df = pd.read_csv('/content/adult.data.csv')
df
# How many of each race are represented in this dataset? This should be a Pandas series with race names as the index labels.
race_count = pd.value_counts(df.race)
race_count
# What is the average age of men?
df.age[df.sex=='Male'].mean()
# What is the percentage of people who have a Bachelor's degree?
percentage_bachelors = df.education[df.education=='Bachelors'].count()*100/df.education.count()
percentage_bachelors
df50k = df[df.salary=='>50K']
df50k
# What percentage of people with advanced education (`Bachelors`, `Masters`, or `Doctorate`) make more than 50K?
# What percentage of people without advanced education make more than 50K?
higher_education = df.education[(df.education=='Bachelors') | (df.education=='Masters') | (df.education=='Doctorate')].count()
education_counts = pd.value_counts(df.education)
education_counts
lower_education = df.education.count() - higher_education
lower_education
higher_education_rich = df50k.education[(df50k.education=='Bachelors') | (df50k.education=='Masters') | (df50k.education=='Doctorate')].count()
lower_education_rich = df50k.education.count() - higher_education_rich
lower_education_rich
higher_education_rich = higher_education_rich*100/df.education.count()
lower_education_rich = lower_education_rich*100/df.education.count()
higher_education_rich
df['hours-per-week'].describe()
min_work_hours = df['hours-per-week'].min()
min_work_hours
# What percentage of the people who work the minimum number of hours per week have a salary of >50K?
(df['hours-per-week'] == min_work_hours).values.sum()
(df50k['hours-per-week'] == min_work_hours).values.sum()
rich_percentage = (df50k['hours-per-week'] == min_work_hours).values.sum()*100/(df['hours-per-week'] == min_work_hours).values.sum()
rich_percentage
# What country has the highest percentage of people that earn >50K?
df50k['native-country'].value_counts().rename_axis('native-country').reset_index(name='>50k')
df['native-country'].value_counts().rename_axis('native-country').reset_index(name='all')
perdf = pd.merge(df50k['native-country'].value_counts().rename_axis('native-country').reset_index(name='>50k'),df['native-country'].value_counts().rename_axis('native-country').reset_index(name='all'),how='outer',on='native-country')
perdf
perdf['percentage'] = perdf['>50k']*100/perdf['all']
perdf = perdf.sort_values('percentage', ascending=False)
perdf
perdf.loc[perdf.index[0],'native-country']

# Identify the most popular occupation for those who earn >50K in India.
(df50k[df50k['native-country'] == 'India'].occupation.value_counts()).index[0]
countries = pd.DataFrame(df['native-country'].value_counts().reset_index())
countries.columns = ['country','count']
countries50k = pd.DataFrame(df50k['native-country'].value_counts().reset_index())
countries50k.columns = ['country','count50k']
c_df = pd.merge(countries, countries50k, how='outer',on='country')
c_df<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15695364238410597, 'fraction_numerical': 0.023509933774834436, 'mean_word_length': 7.911504424778761, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '199014', 'license': 'MIT', 'n_tokens_mistral': 1089, 'n_tokens_neox': 980, 'n_words': 190, 'path': 'demographicDataAnalysis.ipynb', 'repo_name': 'ParameshMalla/dataSciencePractiseNotebooks', 'size': '3020'}