src/04_visualization/census_vis_synthesis.py
def clean_education(education, year):
        """
        This function cleans the education census data
        Args:
            education (pd.DataFrame): The dataframe for education data
            year (int): census year

        Returns:
            education: A cleaned pandas dataframe
        """

        if year == 2001:
            no_deg = education[
                'population 20 years and over - Less than grade 9'] + education[
                'population 20 years and over - Grades 9 to 13'] + education[
                'population 20 years and over - Without High school diploma or equivalent']

            high = education['population 20 years and over - High school diploma or equivalent']
            trade = education['population 20 years and over - Apprenticeship or trades certificate or diploma']
            college = education[
                'population 20 years and over - College'] + education[
                'population 20 years and over - College without certificate or diploma'] + education[
                'population 20 years and over - College, CEGEP or other non-university certificate or diploma']

            total = education['Total population 20 years and over']

        elif year == 2006:
            no_deg = education['population aged 15 years and over - No certificate, diploma or degree']
            high = education['population aged 15 years and over - High school certificate or equivalent']
            trade = education['population aged 15 years and over - Apprenticeship or trades certificate or diploma']
            college = education['population aged 15 years and over - College, CEGEP or other non-university certificate or diploma']
            total = education['Total population aged 15 years and over']

        elif year in [2011, 2016]:
            no_deg = education['population aged 15 years and over - No certificate, diploma or degree']
            high = education['population aged 15 years and over - High school diploma or equivalent']
            trade = education['population aged 15 years and over - Apprenticeship or trades certificate or diploma']
            college = education['population aged 15 years and over - College, CEGEP or other non-university certificate or diploma']
            total = education['Total population aged 15 years and over']
            if year == 2011:
                education = education.query('Type == "Total"')
                van_total = education.sum()
                van_total['LocalArea'] = 'City of Vancouver'
                van_total['Type'] = 'Total'
                education = education.append(van_total, ignore_index=True)

        uni = total - no_deg - high - trade - college
        education['No certificate/diploma'] = no_deg/total
        education['High school'] = high/total
        education['Apprenticeship/Trades'] = trade/total
        education['College'] = college/total
        education['University'] = uni/total

        education = education[['LocalArea',
                               'No certificate/diploma',
                               'High school',
                               'Apprenticeship/Trades',
                               'College',
                               'University']]

        return education

        This function cleans the education census data
        Args:
            education (pd.DataFrame): The dataframe for education data
            year (int): census year

        Returns:
            education: A cleaned pandas dataframe
        
This function cleans the education census data
This function cleans the education census data
def clean_education(education, year):
        if year == 2001:
            no_deg = education[
                'population 20 years and over - Less than grade 9'] + education[
                'population 20 years and over - Grades 9 to 13'] + education[
                'population 20 years and over - Without High school diploma or equivalent']
            high = education['population 20 years and over - High school diploma or equivalent']
            trade = education['population 20 years and over - Apprenticeship or trades certificate or diploma']
            college = education[
                'population 20 years and over - College'] + education[
                'population 20 years and over - College without certificate or diploma'] + education[
                'population 20 years and over - College, CEGEP or other non-university certificate or diploma']
            total = education['Total population 20 years and over']
        elif year == 2006:
            no_deg = education['population aged 15 years and over - No certificate, diploma or degree']
            high = education['population aged 15 years and over - High school certificate or equivalent']
            trade = education['population aged 15 years and over - Apprenticeship or trades certificate or diploma']
            college = education['population aged 15 years and over - College, CEGEP or other non-university certificate or diploma']
            total = education['Total population aged 15 years and over']
        elif year in [2011, 2016]:
            no_deg = education['population aged 15 years and over - No certificate, diploma or degree']
            high = education['population aged 15 years and over - High school diploma or equivalent']
            trade = education['population aged 15 years and over - Apprenticeship or trades certificate or diploma']
            college = education['population aged 15 years and over - College, CEGEP or other non-university certificate or diploma']
            total = education['Total population aged 15 years and over']
            if year == 2011:
                education = education.query('Type == "Total"')
                van_total = education.sum()
                van_total['LocalArea'] = 'City of Vancouver'
                van_total['Type'] = 'Total'
                education = education.append(van_total, ignore_index=True)
        uni = total - no_deg - high - trade - college
        education['No certificate/diploma'] = no_deg/total
        education['High school'] = high/total
        education['Apprenticeship/Trades'] = trade/total
        education['College'] = college/total
        education['University'] = uni/total
        education = education[['LocalArea',
                               'No certificate/diploma',
                               'High school',
                               'Apprenticeship/Trades',
                               'College',
                               'University']]
        return education
def clean_education ( education , year ) : if year == 2001 : no_deg = education [ 'population 20 years and over - Less than grade 9' ] + education [ 'population 20 years and over - Grades 9 to 13' ] + education [ 'population 20 years and over - Without High school diploma or equivalent' ] high = education [ 'population 20 years and over - High school diploma or equivalent' ] trade = education [ 'population 20 years and over - Apprenticeship or trades certificate or diploma' ] college = education [ 'population 20 years and over - College' ] + education [ 'population 20 years and over - College without certificate or diploma' ] + education [ 'population 20 years and over - College, CEGEP or other non-university certificate or diploma' ] total = education [ 'Total population 20 years and over' ] elif year == 2006 : no_deg = education [ 'population aged 15 years and over - No certificate, diploma or degree' ] high = education [ 'population aged 15 years and over - High school certificate or equivalent' ] trade = education [ 'population aged 15 years and over - Apprenticeship or trades certificate or diploma' ] college = education [ 'population aged 15 years and over - College, CEGEP or other non-university certificate or diploma' ] total = education [ 'Total population aged 15 years and over' ] elif year in [ 2011 , 2016 ] : no_deg = education [ 'population aged 15 years and over - No certificate, diploma or degree' ] high = education [ 'population aged 15 years and over - High school diploma or equivalent' ] trade = education [ 'population aged 15 years and over - Apprenticeship or trades certificate or diploma' ] college = education [ 'population aged 15 years and over - College, CEGEP or other non-university certificate or diploma' ] total = education [ 'Total population aged 15 years and over' ] if year == 2011 : education = education . query ( 'Type == "Total"' ) van_total = education . sum ( ) van_total [ 'LocalArea' ] = 'City of Vancouver' van_total [ 'Type' ] = 'Total' education = education . append ( van_total , ignore_index = True ) uni = total - no_deg - high - trade - college education [ 'No certificate/diploma' ] = no_deg / total education [ 'High school' ] = high / total education [ 'Apprenticeship/Trades' ] = trade / total education [ 'College' ] = college / total education [ 'University' ] = uni / total education = education [ [ 'LocalArea' , 'No certificate/diploma' , 'High school' , 'Apprenticeship/Trades' , 'College' , 'University' ] ] return education
This function cleans the education census data
This function cleans the education census data
"""
        This function cleans the education census data
        Args:
            education (pd.DataFrame): The dataframe for education data
            year (int): census year

        Returns:
            education: A cleaned pandas dataframe
        """
A cleaned pandas dataframe
A cleaned pandas dataframe
education
education
The dataframe for education data
The dataframe for education data
year
None