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

        Returns:
            family: A cleaned pandas dataframe
        """

        family = family[family['Type'] == 'total couples']
        van_total = family.sum()
        van_total['LocalArea'] = 'City of Vancouver'
        van_total['Type'] = 'total couples'
        family = family.append(van_total, ignore_index=True)

        family['Without children at home'] = family[
            'Without children at home']/family['Total']

        family['1 child'] = family['1 child'] / family['Total']

        family['2 children'] = family['2 children'] / family['Total']

        family['3 or more children'] = family['3 or more children'] / \
            family['Total']

        family = family[['LocalArea',
                         'Without children at home',
                         '1 child',
                         '2 children',
                         '3 or more children']]

        return family

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

        Returns:
            family: A cleaned pandas dataframe
        
This function cleans the family census data
This function cleans the family census data
def clean_couples_family_structure(family, year):
        family = family[family['Type'] == 'total couples']
        van_total = family.sum()
        van_total['LocalArea'] = 'City of Vancouver'
        van_total['Type'] = 'total couples'
        family = family.append(van_total, ignore_index=True)
        family['Without children at home'] = family[
            'Without children at home']/family['Total']
        family['1 child'] = family['1 child'] / family['Total']
        family['2 children'] = family['2 children'] / family['Total']
        family['3 or more children'] = family['3 or more children'] / \
            family['Total']
        family = family[['LocalArea',
                         'Without children at home',
                         '1 child',
                         '2 children',
                         '3 or more children']]
        return family
def clean_couples_family_structure ( family , year ) : family = family [ family [ 'Type' ] == 'total couples' ] van_total = family . sum ( ) van_total [ 'LocalArea' ] = 'City of Vancouver' van_total [ 'Type' ] = 'total couples' family = family . append ( van_total , ignore_index = True ) family [ 'Without children at home' ] = family [ 'Without children at home' ] / family [ 'Total' ] family [ '1 child' ] = family [ '1 child' ] / family [ 'Total' ] family [ '2 children' ] = family [ '2 children' ] / family [ 'Total' ] family [ '3 or more children' ] = family [ '3 or more children' ] / family [ 'Total' ] family = family [ [ 'LocalArea' , 'Without children at home' , '1 child' , '2 children' , '3 or more children' ] ] return family
This function cleans the family census data
This function cleans the family census data
"""
        This function cleans the family census data
        Args:
            family (pd.DataFrame): The dataframe for family data
            year (int): census year

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