src/04_visualization/census_vis_synthesis.py
def clean_household_size(house_size, year):
        """
        This function cleans the household size census data
        Args:
            house_size (pd.DataFrame): The dataframe for household size data
            year (int): census year

        Returns:
            house_size: A cleaned pandas dataframe
        """

        col_lis = list(house_size.columns)[3:8]
        for col in col_lis:
            house_size[col] = house_size[col] / house_size['Total households']

        house_size.rename(
            columns={'1 person': '1 person',
                     '2 persons': '2 persons',
                     '3 persons': '3 persons',
                     '4 persons': '4 to 5 persons',
                     '5 or more persons': '6+ persons',
                     '4 to 5 persons': '4 to 5 persons',
                     '6 or more persons': '6+ persons'},
            inplace=True)

        house_size = house_size[['LocalArea', '1 person',
                                 '2 persons', '3 persons',
                                 '4 to 5 persons',
                                 '6+ persons']]

        return house_size

        This function cleans the household size census data
        Args:
            house_size (pd.DataFrame): The dataframe for household size data
            year (int): census year

        Returns:
            house_size: A cleaned pandas dataframe
        
This function cleans the household size census data
This function cleans the household size census data
def clean_household_size(house_size, year):
        col_lis = list(house_size.columns)[3:8]
        for col in col_lis:
            house_size[col] = house_size[col] / house_size['Total households']
        house_size.rename(
            columns={'1 person': '1 person',
                     '2 persons': '2 persons',
                     '3 persons': '3 persons',
                     '4 persons': '4 to 5 persons',
                     '5 or more persons': '6+ persons',
                     '4 to 5 persons': '4 to 5 persons',
                     '6 or more persons': '6+ persons'},
            inplace=True)
        house_size = house_size[['LocalArea', '1 person',
                                 '2 persons', '3 persons',
                                 '4 to 5 persons',
                                 '6+ persons']]
        return house_size
def clean_household_size ( house_size , year ) : col_lis = list ( house_size . columns ) [ 3 : 8 ] for col in col_lis : house_size [ col ] = house_size [ col ] / house_size [ 'Total households' ] house_size . rename ( columns = { '1 person' : '1 person' , '2 persons' : '2 persons' , '3 persons' : '3 persons' , '4 persons' : '4 to 5 persons' , '5 or more persons' : '6+ persons' , '4 to 5 persons' : '4 to 5 persons' , '6 or more persons' : '6+ persons' } , inplace = True ) house_size = house_size [ [ 'LocalArea' , '1 person' , '2 persons' , '3 persons' , '4 to 5 persons' , '6+ persons' ] ] return house_size
This function cleans the household size census data
This function cleans the household size census data
"""
        This function cleans the household size census data
        Args:
            house_size (pd.DataFrame): The dataframe for household size data
            year (int): census year

        Returns:
            house_size: A cleaned pandas dataframe
        """
A cleaned pandas dataframe
A cleaned pandas dataframe
house_size
house_size
The dataframe for household size data
The dataframe for household size data
year
None