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

        Returns:
            marital: A cleaned pandas dataframe
        """

        marital['Married or living with a or common-law partner'] = marital[
                'Married or living with a or common-law partner'] / marital[
                'Total population 15 years and over']

        marital[
            'Not living with a married spouse or common-law partner'] = marital[
            'Not living with a married spouse or common-law partner']/marital[
            'Total population 15 years and over']

        if year == 2011 or year == 2016:
            marital = marital.query('Type == "total"')
            van_total = marital.sum()
            van_total['LocalArea'] = 'City of Vancouver'
            van_total['Type'] = 'total'
            marital = marital.append(van_total, ignore_index=True)

        marital = marital[[
            'LocalArea',
            'Married or living with a or common-law partner',
            'Not living with a married spouse or common-law partner']]

        return marital

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

        Returns:
            marital: A cleaned pandas dataframe
        
This function cleans the marital census data
This function cleans the marital census data
def clean_marital_status(marital, year):
        marital['Married or living with a or common-law partner'] = marital[
                'Married or living with a or common-law partner'] / marital[
                'Total population 15 years and over']
        marital[
            'Not living with a married spouse or common-law partner'] = marital[
            'Not living with a married spouse or common-law partner']/marital[
            'Total population 15 years and over']
        if year == 2011 or year == 2016:
            marital = marital.query('Type == "total"')
            van_total = marital.sum()
            van_total['LocalArea'] = 'City of Vancouver'
            van_total['Type'] = 'total'
            marital = marital.append(van_total, ignore_index=True)
        marital = marital[[
            'LocalArea',
            'Married or living with a or common-law partner',
            'Not living with a married spouse or common-law partner']]
        return marital
def clean_marital_status ( marital , year ) : marital [ 'Married or living with a or common-law partner' ] = marital [ 'Married or living with a or common-law partner' ] / marital [ 'Total population 15 years and over' ] marital [ 'Not living with a married spouse or common-law partner' ] = marital [ 'Not living with a married spouse or common-law partner' ] / marital [ 'Total population 15 years and over' ] if year == 2011 or year == 2016 : marital = marital . query ( 'Type == "total"' ) van_total = marital . sum ( ) van_total [ 'LocalArea' ] = 'City of Vancouver' van_total [ 'Type' ] = 'total' marital = marital . append ( van_total , ignore_index = True ) marital = marital [ [ 'LocalArea' , 'Married or living with a or common-law partner' , 'Not living with a married spouse or common-law partner' ] ] return marital
This function cleans the marital census data
This function cleans the marital census data
"""
        This function cleans the marital census data
        Args:
            marital (pd.DataFrame): The dataframe for language data
            year (int) : Census year

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