src/04_visualization/census_vis_synthesis.py
def clean_immigration_birth_place(im_birth, year):
        """
        This function cleans the immigration birth place census data
        Args:
            im_birth (pd.DataFrame): Dataframe for immigrant birth place data
            year (int): census year

        Returns:
            im_birth: A cleaned pandas dataframe
        """

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

        col_lis = ['Non-immigrants',
                   'Non-permanent residents',
                   'Immigrants']

        for col in col_lis:
            im_birth[col] = im_birth[col]/im_birth['Total population']

        im_birth = im_birth[['LocalArea',
                             'Non-immigrants',
                             'Non-permanent residents',
                             'Immigrants']]

        return im_birth

        This function cleans the immigration birth place census data
        Args:
            im_birth (pd.DataFrame): Dataframe for immigrant birth place data
            year (int): census year

        Returns:
            im_birth: A cleaned pandas dataframe
        
This function cleans the immigration birth place census data
This function cleans the immigration birth place census data
def clean_immigration_birth_place(im_birth, year):
        if year == 2011:
            im_birth = im_birth.query('Type == "Total"')
            van_total = im_birth.sum()
            van_total['LocalArea'] = 'City of Vancouver'
            van_total['Type'] = 'Total'
            im_birth = im_birth.append(van_total, ignore_index=True)
        col_lis = ['Non-immigrants',
                   'Non-permanent residents',
                   'Immigrants']
        for col in col_lis:
            im_birth[col] = im_birth[col]/im_birth['Total population']
        im_birth = im_birth[['LocalArea',
                             'Non-immigrants',
                             'Non-permanent residents',
                             'Immigrants']]
        return im_birth
def clean_immigration_birth_place ( im_birth , year ) : if year == 2011 : im_birth = im_birth . query ( 'Type == "Total"' ) van_total = im_birth . sum ( ) van_total [ 'LocalArea' ] = 'City of Vancouver' van_total [ 'Type' ] = 'Total' im_birth = im_birth . append ( van_total , ignore_index = True ) col_lis = [ 'Non-immigrants' , 'Non-permanent residents' , 'Immigrants' ] for col in col_lis : im_birth [ col ] = im_birth [ col ] / im_birth [ 'Total population' ] im_birth = im_birth [ [ 'LocalArea' , 'Non-immigrants' , 'Non-permanent residents' , 'Immigrants' ] ] return im_birth
This function cleans the immigration birth place census data
This function cleans the immigration birth place census data
"""
        This function cleans the immigration birth place census data
        Args:
            im_birth (pd.DataFrame): Dataframe for immigrant birth place data
            year (int): census year

        Returns:
            im_birth: A cleaned pandas dataframe
        """
A cleaned pandas dataframe
A cleaned pandas dataframe
im_birth
im_birth
Dataframe for immigrant birth place data
Dataframe for immigrant birth place data
year
None