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

        Returns:
            im_p: A cleaned pandas dataframe
        """

        if year == 2001:
            col_names = ['LocalArea',
                         'Total immigrant population',
                         '1996 to 2001']
            im_p = im_p[col_names]
            im_p.rename(columns={'1996 to 2001': 'Immigrates'}, inplace=True)

        elif year == 2006:
            col_names = ['LocalArea',
                         'Total immigrant population',
                         '2001 to 2006']
            im_p = im_p[col_names]
            im_p.rename(columns={'2001 to 2006': 'Immigrates'}, inplace=True)

        elif year == 2011:
            col_names = ['LocalArea',
                         'Immigrants',
                         '2006 to 2010']
            im_p = im_p[col_names]
            im_p.rename(columns={'Immigrants': 'Total immigrant population',
                                 '2006 to 2010': 'Immigrates'}, inplace=True)

        elif year == 2016:
            col_names = ['LocalArea', 'Immigrants', '2011 to 2016']
            im_p = im_p[col_names]
            im_p.rename(columns={'Immigrants': 'Total immigrant population',
                                 '2011 to 2016': 'Immigrates'}, inplace=True)

        im_p['Immigrates'] = im_p[
             'Immigrates'] / im_p[
             'Total immigrant population']

        im_p = im_p[['LocalArea', 'Immigrates']]

        return im_p

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

        Returns:
            im_p: A cleaned pandas dataframe
        
This function cleans the immigration period census data
This function cleans the immigration period census data
def clean_immigration_period(im_p, year):
        if year == 2001:
            col_names = ['LocalArea',
                         'Total immigrant population',
                         '1996 to 2001']
            im_p = im_p[col_names]
            im_p.rename(columns={'1996 to 2001': 'Immigrates'}, inplace=True)
        elif year == 2006:
            col_names = ['LocalArea',
                         'Total immigrant population',
                         '2001 to 2006']
            im_p = im_p[col_names]
            im_p.rename(columns={'2001 to 2006': 'Immigrates'}, inplace=True)
        elif year == 2011:
            col_names = ['LocalArea',
                         'Immigrants',
                         '2006 to 2010']
            im_p = im_p[col_names]
            im_p.rename(columns={'Immigrants': 'Total immigrant population',
                                 '2006 to 2010': 'Immigrates'}, inplace=True)
        elif year == 2016:
            col_names = ['LocalArea', 'Immigrants', '2011 to 2016']
            im_p = im_p[col_names]
            im_p.rename(columns={'Immigrants': 'Total immigrant population',
                                 '2011 to 2016': 'Immigrates'}, inplace=True)
        im_p['Immigrates'] = im_p[
             'Immigrates'] / im_p[
             'Total immigrant population']
        im_p = im_p[['LocalArea', 'Immigrates']]
        return im_p
def clean_immigration_period ( im_p , year ) : if year == 2001 : col_names = [ 'LocalArea' , 'Total immigrant population' , '1996 to 2001' ] im_p = im_p [ col_names ] im_p . rename ( columns = { '1996 to 2001' : 'Immigrates' } , inplace = True ) elif year == 2006 : col_names = [ 'LocalArea' , 'Total immigrant population' , '2001 to 2006' ] im_p = im_p [ col_names ] im_p . rename ( columns = { '2001 to 2006' : 'Immigrates' } , inplace = True ) elif year == 2011 : col_names = [ 'LocalArea' , 'Immigrants' , '2006 to 2010' ] im_p = im_p [ col_names ] im_p . rename ( columns = { 'Immigrants' : 'Total immigrant population' , '2006 to 2010' : 'Immigrates' } , inplace = True ) elif year == 2016 : col_names = [ 'LocalArea' , 'Immigrants' , '2011 to 2016' ] im_p = im_p [ col_names ] im_p . rename ( columns = { 'Immigrants' : 'Total immigrant population' , '2011 to 2016' : 'Immigrates' } , inplace = True ) im_p [ 'Immigrates' ] = im_p [ 'Immigrates' ] / im_p [ 'Total immigrant population' ] im_p = im_p [ [ 'LocalArea' , 'Immigrates' ] ] return im_p
This function cleans the immigration period census data
This function cleans the immigration period census data
"""
        This function cleans the immigration period census data
        Args:
            im_p (pd.DataFrame): The dataframe for immigration period data
            year (int): census year

        Returns:
            im_p: A cleaned pandas dataframe
        """
A cleaned pandas dataframe
A cleaned pandas dataframe
im_p
im_p
The dataframe for immigration period data
The dataframe for immigration period data
year
None