src/04_visualization/census_vis_synthesis.py
def clean_mobility(mob, year):
        """
        This function cleans the population mobility census data
        Args:
            mob (pd.DataFrame): The dataframe for mobility data
            year (int): census year

        Returns:
            mob: A cleaned pandas dataframe
        """

        mob['total'] = mob[
                'Non-movers 1 yr ago'] + mob[
                'Non-migrants 1 yr ago'] + mob[
                'Migrants 1 yr ago']

        mob['Non-movers 1 yr ago'] = mob[
            'Non-movers 1 yr ago'] / mob['total']
        mob['Non-migrants 1 yr ago'] = mob[
            'Non-migrants 1 yr ago'] / mob['total']
        mob['Migrants 1 yr ago'] = mob[
            'Migrants 1 yr ago'] / mob['total']

        mob = mob[['LocalArea',
                   'Non-movers 1 yr ago',
                   'Non-migrants 1 yr ago',
                   'Migrants 1 yr ago']]

        return mob

        This function cleans the population mobility census data
        Args:
            mob (pd.DataFrame): The dataframe for mobility data
            year (int): census year

        Returns:
            mob: A cleaned pandas dataframe
        
This function cleans the population mobility census data
This function cleans the population mobility census data
def clean_mobility(mob, year):
        mob['total'] = mob[
                'Non-movers 1 yr ago'] + mob[
                'Non-migrants 1 yr ago'] + mob[
                'Migrants 1 yr ago']
        mob['Non-movers 1 yr ago'] = mob[
            'Non-movers 1 yr ago'] / mob['total']
        mob['Non-migrants 1 yr ago'] = mob[
            'Non-migrants 1 yr ago'] / mob['total']
        mob['Migrants 1 yr ago'] = mob[
            'Migrants 1 yr ago'] / mob['total']
        mob = mob[['LocalArea',
                   'Non-movers 1 yr ago',
                   'Non-migrants 1 yr ago',
                   'Migrants 1 yr ago']]
        return mob
def clean_mobility ( mob , year ) : mob [ 'total' ] = mob [ 'Non-movers 1 yr ago' ] + mob [ 'Non-migrants 1 yr ago' ] + mob [ 'Migrants 1 yr ago' ] mob [ 'Non-movers 1 yr ago' ] = mob [ 'Non-movers 1 yr ago' ] / mob [ 'total' ] mob [ 'Non-migrants 1 yr ago' ] = mob [ 'Non-migrants 1 yr ago' ] / mob [ 'total' ] mob [ 'Migrants 1 yr ago' ] = mob [ 'Migrants 1 yr ago' ] / mob [ 'total' ] mob = mob [ [ 'LocalArea' , 'Non-movers 1 yr ago' , 'Non-migrants 1 yr ago' , 'Migrants 1 yr ago' ] ] return mob
This function cleans the population mobility census data
This function cleans the population mobility census data
"""
        This function cleans the population mobility census data
        Args:
            mob (pd.DataFrame): The dataframe for mobility data
            year (int): census year

        Returns:
            mob: A cleaned pandas dataframe
        """
A cleaned pandas dataframe
A cleaned pandas dataframe
mob
mob
The dataframe for mobility data
The dataframe for mobility data
year
None