src/04_visualization/census_vis_synthesis.py
def clean_workplace_status(wp, year):
        """
        This function cleans the workplace status census data
        Args:
            wp (pd.DataFrame): The dataframe for workplace status data
            year (int): census year

        Returns:
            wp: A cleaned pandas dataframe
        """

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

        cols = list(wp.columns)[3:]
        wp['total'] = wp[list(wp.columns)[3]] + wp[
                        list(wp.columns)[4]] + wp[
                        list(wp.columns)[5]] + wp[
                        list(wp.columns)[6]]

        for c in cols:
            wp[c] = wp[c]/wp['total']

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

        return wp

        This function cleans the workplace status census data
        Args:
            wp (pd.DataFrame): The dataframe for workplace status data
            year (int): census year

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

        Returns:
            wp: A cleaned pandas dataframe
        """
A cleaned pandas dataframe
A cleaned pandas dataframe
wp
wp
The dataframe for workplace status data
The dataframe for workplace status data
year
None