<jupyter_start><jupyter_text>Business understandingThese are the questions i'm interested in answering1. What are the top 5 countries with the highest job satisfaction?2. Which countries have the most HoursPerWeek?3. Do larger companies have professionals with higher salaries?  Data Understanding<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

df = pd.read_csv('./survey_results_public.csv')
schema = pd.read_csv('./survey_results_schema.csv')
df.head()<jupyter_output><empty_output><jupyter_text>Prepare Data<jupyter_code>def group_by(col1, col2, order):
    '''
    Input: 
    col1, col2 - two column names from the dataframe
    order - whether we want the order from ASC or DESC
    
    Output: grouping by the mean of col1 specific to col2. in decsending order with NaN values dropped
    '''
    results = df.groupby([col1]).mean()[col2].sort_values(ascending=[order]).dropna()
    return results
def col_prop(col):
    '''
    Input: 
    col - Column name
    
    Output: Returns the proportion of missing values for the column
    '''
    results = df[col].isnull().mean()
    return results
def graph_prop(df, num2, num=0):
    '''
    Input:
    df - pandas dataframe
    num2: upper bound of results displayed
    num - lower bound of results displayed (optional)
    
    Output:
    a bar graph in proportion to the dataframe given
    '''
    (df[:num2]/df.shape[0]).plot(kind="bar", color=('blue'))
def graph(df, num2, num=0):
    '''
    Input:
    df - pandas dataframe
    num2: upper bound of results displayed
    num - lower bound of results displayed
    
    Output:
    a bar graph to the dataframe given
    '''
    (df[num:num2]).plot(kind="bar", color=('blue'))
#Groups Job Satisifcation by Country
country_sat = group_by('Country', 'JobSatisfaction', False)
country_sat.head()
# proportion of missing values in the Job Satisfaction column
# These null values were dropped from the dataframe
col_prop('JobSatisfaction')
# Groups HoursPerWeek by Country
mostWorked = group_by('Country','HoursPerWeek', True)
mostWorked.head()
# proportion of missing values in the HoursPerWeek column
# These null values were dropped from the dataframe
col_prop('HoursPerWeek')
# Group HoursPerWeek by Country
countryEducation = group_by('CompanySize','Salary', False)
countryEducation.head()
# proportion of missing values in the Salary column
# These null values were dropped from the dataframe leaving 27% for analysis (possibly not the best apporach)
col_prop('Salary')<jupyter_output><empty_output><jupyter_text>Data Modeling<jupyter_code>#graphs Job Satisifcation by Country
graph_prop(country_sat, 10)
#graphs HoursperWork by Country
graph(mostWorked, 20, 10)
#graphs HoursPerWeek by Country
graph(countryEducation, 10)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09232401839405731, 'fraction_numerical': 0.010965688008489564, 'mean_word_length': 4.566929133858268, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '164302', 'license': 'FTL', 'n_tokens_mistral': 871, 'n_tokens_neox': 826, 'n_words': 288, 'path': 'Write a Data science blogpost.ipynb', 'repo_name': 'franckyvaval/Write-A-Data-Science-Blog-Post', 'size': '2827'}