src/02_clean_wrangle/06_synthesis.py
def clean_couples_family_structure(family, start_year, end_year):
        """
        This function cleans the family census data
        Args:
            family (pandas dataframe): The dataframe for family data
            start_year (int): The four digit start year
            end_year (int): The four digit end year, note end year not included

        Returns:
            family: A cleaned pandas dataframe

        """
        assert check_columns(family, ['Type', 'LocalArea',
                         'Without children at home',
                         '1 child',
                         '2 children',
                         '3 or more children']), 'Input dataframe does not have all columns required'

        family = family[family['Type'] == 'total couples']

        family['Without children at home'] = family[
            'Without children at home']/family['Total']

        family['1 child'] = family['1 child'] / family['Total']

        family['2 children'] = family['2 children'] / family['Total']

        family['3 or more children'] = family['3 or more children'] / \
            family['Total']

        family = family[['LocalArea',
                         'Without children at home',
                         '1 child',
                         '2 children',
                         '3 or more children']]

        family = fill_missing_year(family, start_year, end_year)

        return family

        This function cleans the family census data
        Args:
            family (pandas dataframe): The dataframe for family data
            start_year (int): The four digit start year
            end_year (int): The four digit end year, note end year not included

        Returns:
            family: A cleaned pandas dataframe

        
This function cleans the family census data
This function cleans the family census data
def clean_couples_family_structure(family, start_year, end_year):
        assert check_columns(family, ['Type', 'LocalArea',
                         'Without children at home',
                         '1 child',
                         '2 children',
                         '3 or more children']), 'Input dataframe does not have all columns required'
        family = family[family['Type'] == 'total couples']
        family['Without children at home'] = family[
            'Without children at home']/family['Total']
        family['1 child'] = family['1 child'] / family['Total']
        family['2 children'] = family['2 children'] / family['Total']
        family['3 or more children'] = family['3 or more children'] / \
            family['Total']
        family = family[['LocalArea',
                         'Without children at home',
                         '1 child',
                         '2 children',
                         '3 or more children']]
        family = fill_missing_year(family, start_year, end_year)
        return family
def clean_couples_family_structure ( family , start_year , end_year ) : assert check_columns ( family , [ 'Type' , 'LocalArea' , 'Without children at home' , '1 child' , '2 children' , '3 or more children' ] ) , 'Input dataframe does not have all columns required' family = family [ family [ 'Type' ] == 'total couples' ] family [ 'Without children at home' ] = family [ 'Without children at home' ] / family [ 'Total' ] family [ '1 child' ] = family [ '1 child' ] / family [ 'Total' ] family [ '2 children' ] = family [ '2 children' ] / family [ 'Total' ] family [ '3 or more children' ] = family [ '3 or more children' ] / family [ 'Total' ] family = family [ [ 'LocalArea' , 'Without children at home' , '1 child' , '2 children' , '3 or more children' ] ] family = fill_missing_year ( family , start_year , end_year ) return family
This function cleans the family census data
This function cleans the family census data
"""
        This function cleans the family census data
        Args:
            family (pandas dataframe): The dataframe for family data
            start_year (int): The four digit start year
            end_year (int): The four digit end year, note end year not included

        Returns:
            family: A cleaned pandas dataframe

        """
A cleaned pandas dataframe
A cleaned pandas dataframe
family
family
The dataframe for family data
The dataframe for family data
start_year
The four digit start year
The four digit start year
end_year
The four digit end year, note end year not included
The four digit end year note end year not included