src/04_visualization/census_vis_synthesis.py
def clean_transport_mode(trans, year):
        """
        This function cleans the transport mode census data
        Args:
            trans (pd.DataFrame): The dataframe for transport mode data
            year (int): census year

        Returns:
            trans: A cleaned pandas dataframe
        """

        trans = trans.query('Type == "Total"')
        van_total = trans.sum()
        van_total['LocalArea'] = 'City of Vancouver'
        van_total['Type'] = 'Total'
        trans = trans.append(van_total, ignore_index=True)

        cols = list(trans.columns)[4:]
        for c in cols:
            trans[c] = trans[c]/trans['Total']

        trans.drop(columns=['Unnamed: 0',
                            'Type',
                            'Total'], inplace=True)

        return trans

        This function cleans the transport mode census data
        Args:
            trans (pd.DataFrame): The dataframe for transport mode data
            year (int): census year

        Returns:
            trans: A cleaned pandas dataframe
        
This function cleans the transport mode census data
This function cleans the transport mode census data
def clean_transport_mode(trans, year):
        trans = trans.query('Type == "Total"')
        van_total = trans.sum()
        van_total['LocalArea'] = 'City of Vancouver'
        van_total['Type'] = 'Total'
        trans = trans.append(van_total, ignore_index=True)
        cols = list(trans.columns)[4:]
        for c in cols:
            trans[c] = trans[c]/trans['Total']
        trans.drop(columns=['Unnamed: 0',
                            'Type',
                            'Total'], inplace=True)
        return trans
def clean_transport_mode ( trans , year ) : trans = trans . query ( 'Type == "Total"' ) van_total = trans . sum ( ) van_total [ 'LocalArea' ] = 'City of Vancouver' van_total [ 'Type' ] = 'Total' trans = trans . append ( van_total , ignore_index = True ) cols = list ( trans . columns ) [ 4 : ] for c in cols : trans [ c ] = trans [ c ] / trans [ 'Total' ] trans . drop ( columns = [ 'Unnamed: 0' , 'Type' , 'Total' ] , inplace = True ) return trans
This function cleans the transport mode census data
This function cleans the transport mode census data
"""
        This function cleans the transport mode census data
        Args:
            trans (pd.DataFrame): The dataframe for transport mode data
            year (int): census year

        Returns:
            trans: A cleaned pandas dataframe
        """
A cleaned pandas dataframe
A cleaned pandas dataframe
trans
trans
The dataframe for transport mode data
The dataframe for transport mode data
year
None