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

        Returns:
            occ: A cleaned pandas dataframe
        """

        occ['total'] = occ[
            list(occ.columns)[3]] + occ[list(occ.columns)[4]]

        col_lis = list(occ.columns)[4:]
        for col in col_lis:
            occ[col] = occ[col]/occ['total']

        occ = occ[occ.Type == "Total"]
        van_total = occ.mean()
        van_total['LocalArea'] = 'City of Vancouver'
        van_total['Type'] = 'Total'
        occ = occ.append(van_total, ignore_index=True)

        occ.drop(columns=['Type',
                          'All occupations',
                          'Unnamed: 0',
                          'total'], inplace=True)

        return occ

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

        Returns:
            occ: A cleaned pandas dataframe
        
This function cleans the occupational census data
This function cleans the occupational census data
def clean_occupation(occ, year):
        occ['total'] = occ[
            list(occ.columns)[3]] + occ[list(occ.columns)[4]]
        col_lis = list(occ.columns)[4:]
        for col in col_lis:
            occ[col] = occ[col]/occ['total']
        occ = occ[occ.Type == "Total"]
        van_total = occ.mean()
        van_total['LocalArea'] = 'City of Vancouver'
        van_total['Type'] = 'Total'
        occ = occ.append(van_total, ignore_index=True)
        occ.drop(columns=['Type',
                          'All occupations',
                          'Unnamed: 0',
                          'total'], inplace=True)
        return occ
def clean_occupation ( occ , year ) : occ [ 'total' ] = occ [ list ( occ . columns ) [ 3 ] ] + occ [ list ( occ . columns ) [ 4 ] ] col_lis = list ( occ . columns ) [ 4 : ] for col in col_lis : occ [ col ] = occ [ col ] / occ [ 'total' ] occ = occ [ occ . Type == "Total" ] van_total = occ . mean ( ) van_total [ 'LocalArea' ] = 'City of Vancouver' van_total [ 'Type' ] = 'Total' occ = occ . append ( van_total , ignore_index = True ) occ . drop ( columns = [ 'Type' , 'All occupations' , 'Unnamed: 0' , 'total' ] , inplace = True ) return occ
This function cleans the occupational census data
This function cleans the occupational census data
"""
        This function cleans the occupational census data
        Args:
            occ (pd.DataFrame): The dataframe for occupation data
            year (int): census year

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