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

        Returns:
            dwel: A cleaned pandas dataframe
        """

        dwel['House'] = (dwel[
            'Single-detached house'] + dwel[
            'Semi-detached house'] + dwel[
            'Row house']) / dwel['Total']

        if year == 2001:
            dwel['Apartment (<5 storeys)'] = (dwel[
                    'Apartment, detached duplex'] + dwel[
                    'Apartment, building that has fewer than five storeys'
                    ]) / dwel['Total']
            dwel['Apartment (5+ storeys)'] =  dwel[
                    'Apartment, building that has five or more storeys'
                    ] / dwel['Total']

            dwel['dwelling_Other'] = (
                dwel['Other single-attached house'] + dwel[
                    'Movable dwelling']) / dwel['Total']

        elif year == 2006:
            dwel['Apartment (<5 storeys)'] = dwel[
                 'Apartment, duplex'] /dwel['Total']
            dwel['Apartment (5+ storeys)'] =  dwel[
                    'Apartment, building that has five or more storeys'
                    ] / dwel['Total']

            dwel['dwelling_Other'] = 1 - dwel[
                    'Apartment (5+ storeys)'] - dwel[
                    'Apartment (<5 storeys)'] - dwel[
                    'House']

        else:
            dwel['Apartment (<5 storeys)'] = (dwel[
                 'Apartment, detached duplex'] + dwel[
                 'Apartment, building that has fewer than five storeys'
                ]) / dwel['Total']
            dwel['Apartment (5+ storeys)'] =  dwel[
                    'Apartment, building that has five or more storeys'
                    ] / dwel['Total']

            dwel['dwelling_Other'] = 1 - dwel[
                    'Apartment (5+ storeys)'] - dwel[
                    'Apartment (<5 storeys)'] - dwel[
                    'House']

        dwel = dwel[['LocalArea',
                     'Apartment (5+ storeys)',
                     'Apartment (<5 storeys)',
                     'House',
                     'dwelling_Other']]

        return dwel

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

        Returns:
            dwel: A cleaned pandas dataframe
        
This function cleans the dwelling type census data
This function cleans the dwelling type census data
def clean_structural_dwelling_type(dwel, year):
        dwel['House'] = (dwel[
            'Single-detached house'] + dwel[
            'Semi-detached house'] + dwel[
            'Row house']) / dwel['Total']
        if year == 2001:
            dwel['Apartment (<5 storeys)'] = (dwel[
                    'Apartment, detached duplex'] + dwel[
                    'Apartment, building that has fewer than five storeys'
                    ]) / dwel['Total']
            dwel['Apartment (5+ storeys)'] =  dwel[
                    'Apartment, building that has five or more storeys'
                    ] / dwel['Total']
            dwel['dwelling_Other'] = (
                dwel['Other single-attached house'] + dwel[
                    'Movable dwelling']) / dwel['Total']
        elif year == 2006:
            dwel['Apartment (<5 storeys)'] = dwel[
                 'Apartment, duplex'] /dwel['Total']
            dwel['Apartment (5+ storeys)'] =  dwel[
                    'Apartment, building that has five or more storeys'
                    ] / dwel['Total']
            dwel['dwelling_Other'] = 1 - dwel[
                    'Apartment (5+ storeys)'] - dwel[
                    'Apartment (<5 storeys)'] - dwel[
                    'House']
        else:
            dwel['Apartment (<5 storeys)'] = (dwel[
                 'Apartment, detached duplex'] + dwel[
                 'Apartment, building that has fewer than five storeys'
                ]) / dwel['Total']
            dwel['Apartment (5+ storeys)'] =  dwel[
                    'Apartment, building that has five or more storeys'
                    ] / dwel['Total']
            dwel['dwelling_Other'] = 1 - dwel[
                    'Apartment (5+ storeys)'] - dwel[
                    'Apartment (<5 storeys)'] - dwel[
                    'House']
        dwel = dwel[['LocalArea',
                     'Apartment (5+ storeys)',
                     'Apartment (<5 storeys)',
                     'House',
                     'dwelling_Other']]
        return dwel
def clean_structural_dwelling_type ( dwel , year ) : dwel [ 'House' ] = ( dwel [ 'Single-detached house' ] + dwel [ 'Semi-detached house' ] + dwel [ 'Row house' ] ) / dwel [ 'Total' ] if year == 2001 : dwel [ 'Apartment (<5 storeys)' ] = ( dwel [ 'Apartment, detached duplex' ] + dwel [ 'Apartment, building that has fewer than five storeys' ] ) / dwel [ 'Total' ] dwel [ 'Apartment (5+ storeys)' ] = dwel [ 'Apartment, building that has five or more storeys' ] / dwel [ 'Total' ] dwel [ 'dwelling_Other' ] = ( dwel [ 'Other single-attached house' ] + dwel [ 'Movable dwelling' ] ) / dwel [ 'Total' ] elif year == 2006 : dwel [ 'Apartment (<5 storeys)' ] = dwel [ 'Apartment, duplex' ] / dwel [ 'Total' ] dwel [ 'Apartment (5+ storeys)' ] = dwel [ 'Apartment, building that has five or more storeys' ] / dwel [ 'Total' ] dwel [ 'dwelling_Other' ] = 1 - dwel [ 'Apartment (5+ storeys)' ] - dwel [ 'Apartment (<5 storeys)' ] - dwel [ 'House' ] else : dwel [ 'Apartment (<5 storeys)' ] = ( dwel [ 'Apartment, detached duplex' ] + dwel [ 'Apartment, building that has fewer than five storeys' ] ) / dwel [ 'Total' ] dwel [ 'Apartment (5+ storeys)' ] = dwel [ 'Apartment, building that has five or more storeys' ] / dwel [ 'Total' ] dwel [ 'dwelling_Other' ] = 1 - dwel [ 'Apartment (5+ storeys)' ] - dwel [ 'Apartment (<5 storeys)' ] - dwel [ 'House' ] dwel = dwel [ [ 'LocalArea' , 'Apartment (5+ storeys)' , 'Apartment (<5 storeys)' , 'House' , 'dwelling_Other' ] ] return dwel
This function cleans the dwelling type census data
This function cleans the dwelling type census data
"""
        This function cleans the dwelling type census data
        Args:
            dwel (pd.DataFrame): The dataframe for dwelling type data
            year (int): census year

        Returns:
            dwel: A cleaned pandas dataframe
        """
A cleaned pandas dataframe
A cleaned pandas dataframe
dwel
dwel
The dataframe for dwelling type data
The dataframe for dwelling type data
year
None