src/ei_mcoe/ei_mcoe.py
def calc_public_health_damages(pm_cems_df):
    """Create columns for monetary damages for each pollutant.

    Args:
        pm_cems_df (pandas.DataFrame): A DataFrame with all pollutants in lbs
            per year accounted for.
    Returns:
        pandas.DataFrame: A DataFrame with a column containing the monetary
            damages of all pollutants emitted by a given plant or unit in a
            given year.
    """
    logger.info(' - Calculating public health damages from emissions')
    damages_df = pd.DataFrame()
    # Must do a for loop here because x.report_year does not feed into calc_
    # inflation function because it needs to use i
    for year in pm_cems_df['report_year'].unique().tolist():
        year_df = pm_cems_df.loc[pm_cems_df['report_year'] == year]
        try:
            damage_yr_df = (
                year_df.assign(
                    so2_monetized_deaths=lambda x: (
                        tons_to_dollars(x.so2_mass_tons, 'sox')),
                    nox_monetized_deaths=lambda x: (
                        tons_to_dollars(x.nox_mass_tons, 'nox')),
                    pm_monetized_deaths=lambda x: (
                        tons_to_dollars(x.pm_mass_tons, 'pm2.5'))))
            inf1 = calc_inflation(
                'fred', 2006, damage_yr_df, 'so2_monetized_deaths')
            inf2 = calc_inflation('fred', 2006, inf1, 'nox_monetized_deaths')
            inf3 = calc_inflation('fred', 2006, inf2, 'pm_monetized_deaths')
            damage_yr_df_with_infl = (
                inf3.assign(
                    total_monetized_deaths=lambda x: (x.so2_monetized_deaths +
                                                      x.nox_monetized_deaths +
                                                      x.pm_monetized_deaths)))
        except IndexError as error:
            print(f'{year} not accounted for in in inflation index: {error}')
        damages_df = damages_df.append(damage_yr_df_with_infl)
    return damages_df
Create columns for monetary damages for each pollutant.

    Args:
        pm_cems_df (pandas.DataFrame): A DataFrame with all pollutants in lbs
            per year accounted for.
    Returns:
        pandas.DataFrame: A DataFrame with a column containing the monetary
            damages of all pollutants emitted by a given plant or unit in a
            given year.
    
Create columns for monetary damages for each pollutant.
Create columns for monetary damages for each pollutant .
def calc_public_health_damages(pm_cems_df):
    logger.info(' - Calculating public health damages from emissions')
    damages_df = pd.DataFrame()
    for year in pm_cems_df['report_year'].unique().tolist():
        year_df = pm_cems_df.loc[pm_cems_df['report_year'] == year]
        try:
            damage_yr_df = (
                year_df.assign(
                    so2_monetized_deaths=lambda x: (
                        tons_to_dollars(x.so2_mass_tons, 'sox')),
                    nox_monetized_deaths=lambda x: (
                        tons_to_dollars(x.nox_mass_tons, 'nox')),
                    pm_monetized_deaths=lambda x: (
                        tons_to_dollars(x.pm_mass_tons, 'pm2.5'))))
            inf1 = calc_inflation(
                'fred', 2006, damage_yr_df, 'so2_monetized_deaths')
            inf2 = calc_inflation('fred', 2006, inf1, 'nox_monetized_deaths')
            inf3 = calc_inflation('fred', 2006, inf2, 'pm_monetized_deaths')
            damage_yr_df_with_infl = (
                inf3.assign(
                    total_monetized_deaths=lambda x: (x.so2_monetized_deaths +
                                                      x.nox_monetized_deaths +
                                                      x.pm_monetized_deaths)))
        except IndexError as error:
            print(f'{year} not accounted for in in inflation index: {error}')
        damages_df = damages_df.append(damage_yr_df_with_infl)
    return damages_df
def calc_public_health_damages ( pm_cems_df ) : logger . info ( ' - Calculating public health damages from emissions' ) damages_df = pd . DataFrame ( ) for year in pm_cems_df [ 'report_year' ] . unique ( ) . tolist ( ) : year_df = pm_cems_df . loc [ pm_cems_df [ 'report_year' ] == year ] try : damage_yr_df = ( year_df . assign ( so2_monetized_deaths = lambda x : ( tons_to_dollars ( x . so2_mass_tons , 'sox' ) ) , nox_monetized_deaths = lambda x : ( tons_to_dollars ( x . nox_mass_tons , 'nox' ) ) , pm_monetized_deaths = lambda x : ( tons_to_dollars ( x . pm_mass_tons , 'pm2.5' ) ) ) ) inf1 = calc_inflation ( 'fred' , 2006 , damage_yr_df , 'so2_monetized_deaths' ) inf2 = calc_inflation ( 'fred' , 2006 , inf1 , 'nox_monetized_deaths' ) inf3 = calc_inflation ( 'fred' , 2006 , inf2 , 'pm_monetized_deaths' ) damage_yr_df_with_infl = ( inf3 . assign ( total_monetized_deaths = lambda x : ( x . so2_monetized_deaths + x . nox_monetized_deaths + x . pm_monetized_deaths ) ) ) except IndexError as error : print ( f'{year} not accounted for in in inflation index: {error}' ) damages_df = damages_df . append ( damage_yr_df_with_infl ) return damages_df
Create columns for monetary damages for each pollutant.
Create columns for monetary damages for each pollutant .
"""Create columns for monetary damages for each pollutant.

    Args:
        pm_cems_df (pandas.DataFrame): A DataFrame with all pollutants in lbs
            per year accounted for.
    Returns:
        pandas.DataFrame: A DataFrame with a column containing the monetary
            damages of all pollutants emitted by a given plant or unit in a
            given year.
    """ # Must do a for loop here because x.report_year does not feed into calc_ # inflation function because it needs to use i
A DataFrame with a column containing the monetary
damages of all pollutants emitted by a given plant or unit in a
given year.
A DataFrame with a column containing the monetary damages of all pollutants emitted by a given plant or unit in a given year .
pandas.DataFrame
pm_cems_df
A DataFrame with all pollutants in lbs
per year accounted for.
A DataFrame with all pollutants in lbs per year accounted for .