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

        Returns:
            age: A cleaned pandas dataframe

        """
        assert check_columns(age, ['Type']), 'Input dataframe does not have all columns required'

        age = age[age['Type'] == 'total']

        age['age below 20'] = (age[
            '0 to 4 years'] + age[
            '5 to 9 years'] + age[
            '10 to 14 years'] + age[
            '15 to 19 years'])/age['Total']

        age['age between 20 and 35'] = (
            age['20 to 24 years'] + age[
                '25 to 29 years'] + age[
                '30 to 34 years'])/age['Total']

        age['age between 35 and 60'] = (
            age['35 to 39 years'] + age[
                '40 to 44 years'] + age[
                '45 to 49 years'] + age[
                '50 to 54 years'] + age[
                '55 to 59 years'])/age['Total']

        age['age above 60'] = 1 - (
            age['age below 20'] + age[
                'age between 20 and 35'] + age[
                'age between 35 and 60'])

        age = age[['LocalArea', 'age below 20',
                   'age between 20 and 35',
                   'age between 35 and 60',
                   'age above 60']]

        age = fill_missing_year(age, start_year, end_year)
        return age

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

        Returns:
            age: A cleaned pandas dataframe

        
This function cleans the marital census data
This function cleans the marital census data
def clean_age(age, start_year, end_year):
        assert check_columns(age, ['Type']), 'Input dataframe does not have all columns required'
        age = age[age['Type'] == 'total']
        age['age below 20'] = (age[
            '0 to 4 years'] + age[
            '5 to 9 years'] + age[
            '10 to 14 years'] + age[
            '15 to 19 years'])/age['Total']
        age['age between 20 and 35'] = (
            age['20 to 24 years'] + age[
                '25 to 29 years'] + age[
                '30 to 34 years'])/age['Total']
        age['age between 35 and 60'] = (
            age['35 to 39 years'] + age[
                '40 to 44 years'] + age[
                '45 to 49 years'] + age[
                '50 to 54 years'] + age[
                '55 to 59 years'])/age['Total']
        age['age above 60'] = 1 - (
            age['age below 20'] + age[
                'age between 20 and 35'] + age[
                'age between 35 and 60'])
        age = age[['LocalArea', 'age below 20',
                   'age between 20 and 35',
                   'age between 35 and 60',
                   'age above 60']]
        age = fill_missing_year(age, start_year, end_year)
        return age
def clean_age ( age , start_year , end_year ) : assert check_columns ( age , [ 'Type' ] ) , 'Input dataframe does not have all columns required' age = age [ age [ 'Type' ] == 'total' ] age [ 'age below 20' ] = ( age [ '0 to 4 years' ] + age [ '5 to 9 years' ] + age [ '10 to 14 years' ] + age [ '15 to 19 years' ] ) / age [ 'Total' ] age [ 'age between 20 and 35' ] = ( age [ '20 to 24 years' ] + age [ '25 to 29 years' ] + age [ '30 to 34 years' ] ) / age [ 'Total' ] age [ 'age between 35 and 60' ] = ( age [ '35 to 39 years' ] + age [ '40 to 44 years' ] + age [ '45 to 49 years' ] + age [ '50 to 54 years' ] + age [ '55 to 59 years' ] ) / age [ 'Total' ] age [ 'age above 60' ] = 1 - ( age [ 'age below 20' ] + age [ 'age between 20 and 35' ] + age [ 'age between 35 and 60' ] ) age = age [ [ 'LocalArea' , 'age below 20' , 'age between 20 and 35' , 'age between 35 and 60' , 'age above 60' ] ] age = fill_missing_year ( age , start_year , end_year ) return age
This function cleans the marital census data
This function cleans the marital census data
"""
        This function cleans the marital census data
        Args:
            age (pandas dataframe): The dataframe for population data
            start_year (int): The four digit start year
            end_year (int): The four digit end year, note end year not included

        Returns:
            age: A cleaned pandas dataframe

        """
A cleaned pandas dataframe
A cleaned pandas dataframe
age
age
The dataframe for population data
The dataframe for population 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