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

        Returns:
            shel: A cleaned pandas dataframe
        """

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

        shel['Owned_Rented'] = shel['Owned'] + shel['Rented']
        shel['Owned'] = shel['Owned'] / shel['Owned_Rented']
        shel['Rented'] = shel['Rented'] / shel['Owned_Rented']

        shel = shel[['LocalArea', 'Owned', 'Rented']]

        return shel

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

        Returns:
            shel: A cleaned pandas dataframe
        
This function cleans the shelter tenure census data
This function cleans the shelter tenure census data
def clean_shelter_tenure(shel, year):
        if year == 2011:
            shel = shel.query('Type == "Total"')
            van_total = shel.sum()
            van_total['LocalArea'] = 'City of Vancouver'
            van_total['Type'] = 'Total'
            shel = shel.append(van_total, ignore_index=True)
        shel['Owned_Rented'] = shel['Owned'] + shel['Rented']
        shel['Owned'] = shel['Owned'] / shel['Owned_Rented']
        shel['Rented'] = shel['Rented'] / shel['Owned_Rented']
        shel = shel[['LocalArea', 'Owned', 'Rented']]
        return shel
def clean_shelter_tenure ( shel , year ) : if year == 2011 : shel = shel . query ( 'Type == "Total"' ) van_total = shel . sum ( ) van_total [ 'LocalArea' ] = 'City of Vancouver' van_total [ 'Type' ] = 'Total' shel = shel . append ( van_total , ignore_index = True ) shel [ 'Owned_Rented' ] = shel [ 'Owned' ] + shel [ 'Rented' ] shel [ 'Owned' ] = shel [ 'Owned' ] / shel [ 'Owned_Rented' ] shel [ 'Rented' ] = shel [ 'Rented' ] / shel [ 'Owned_Rented' ] shel = shel [ [ 'LocalArea' , 'Owned' , 'Rented' ] ] return shel
This function cleans the shelter tenure census data
This function cleans the shelter tenure census data
"""
        This function cleans the shelter tenure census data
        Args:
            shel (pd.DataFrame): The dataframe for shelter tenure data
            year (int): census year

        Returns:
            shel: A cleaned pandas dataframe
        """
A cleaned pandas dataframe
A cleaned pandas dataframe
shel
shel
The dataframe for shelter tenure data
The dataframe for shelter tenure data
year
None