<jupyter_start><jupyter_text><jupyter_code>import numpy as np
import pandas as pd

df = pd.read_csv('/adult.data.csv')
#df.head()
#1.
#race_count = df['race'].value_counts()
#race_count
#2.
#avg_men = round(df[df["sex"]=='Male']['age'].mean(),1)
#avg_men

#3.

# bacherlors_degree = len(df[df['education']== 'Bachelors'])
# print(bacherlors_degree)
# total_degree = len(df)
# #print(total_degree)
# percentage_bachelors = round(bacherlors_degree/total_degree * 100 , 1)
# print(percentage_bachelors)

#4.

# more_than_one = df[df['education'].isin(['Bachelors', 'Masters', 'Masters'])]
# print(more_than_one) #7078 rows
# not_more_than_one = df[~df['education'].isin(['Bachelors', 'Masters', 'Masters'])]
# print(not_more_than_one) #25483 rows

# num_of_higher = len(more_than_one[more_than_one.salary == '>50K'])
# print(num_of_higher)
# num_of_lower = len(not_more_than_one[not_more_than_one.salary == '>50K'])
# print(num_of_lower)

# high_education_rich = round(num_of_higher / len(more_than_one) * 100 , 1)
# lower_education_rich = round(num_of_lower / len(not_more_than_one) * 100 , 1)
# print(high_education_rich)
# print(lower_education_rich)

#5. 

# min_work = df['hours-per-week'].min()
# print(min_work)

#6. 

# min_num_workers = (df[df['hours-per-week'] == min_work])
# # print(min_num_workers)
# rich_min_work_percentage = len(min_num_workers[min_num_workers['salary']== '>50K']) / len(min_num_workers) * 100 
# print(rich_min_work_percentage)

#7.

country_count = df['native-country'].value_counts()
# print(country_count)
country_rich_count = df[df['salary'] == '>50K']['native-country'].value_counts()
# print(country_rich_count)

# country_count = len(df['native-country'])
# print(country_count)
# country_rich_count = len(df[df['salary'] == '>50K']['native-country'])
# print(country_rich_count)


highest_earning_country = (country_rich_count / country_count * 100 ).max() #sort_values(ascending = False)
print(highest_earning_country)

#8. 

occupation_values = df[(df['native-country'] == 'India') & (df['salary'] == '>50K')]
occupation_counts = occupation_values.occupation.value_counts()
top_IN_occupation = occupation_counts.idxmax()
print(top_IN_occupation)<jupyter_output>41.86046511627907
Prof-specialty
{'fraction_non_alphanumeric': 0.17323187108325871, 'fraction_numerical': 0.02864816472694718, 'mean_word_length': 7.73046875, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 10, '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': '32312', 'license': 'MIT', 'n_tokens_mistral': 947, 'n_tokens_neox': 873, 'n_words': 117, 'path': 'Demographic-Data-Analyzer.ipynb', 'repo_name': 'Mukeshvudayagiri/keep-coding-python', 'size': '2234'}