src/ei_mcoe/ei_mcoe.py
def add_generator_age(with_year_raw_eia_df):
    """Calculate and add a column for generator age.

    This function calculates generator age by subtracting the year the
    generator went into operation from the report year. (EIA data must be run
    through date_to_year() first).

    This is calculated here as opposed to in the eia860.py file because of how
    the 'operating_date' is merged with the rest of the data. It seemed cleaner
    to calculate the generator age here.

    Args:
        with_year_rwa_eia_df (pandas.DataFrame): A DataFrame with raw EIA data
            run through the date_to_year() function.
    Returns:
        pandas.DataFrame: A DataFrame with a new column for generator age.
    """
    logger.info('Calculating generator age')
    gen_df = with_year_raw_eia_df.astype({'operating_date': 'datetime64[ns]'})
    gen_df = gen_df.assign(generator_age_years=(gen_df.report_year -
                                                gen_df.operating_date.dt.year))
    return gen_df
Calculate and add a column for generator age.

    This function calculates generator age by subtracting the year the
    generator went into operation from the report year. (EIA data must be run
    through date_to_year() first).

    This is calculated here as opposed to in the eia860.py file because of how
    the 'operating_date' is merged with the rest of the data. It seemed cleaner
    to calculate the generator age here.

    Args:
        with_year_rwa_eia_df (pandas.DataFrame): A DataFrame with raw EIA data
            run through the date_to_year() function.
    Returns:
        pandas.DataFrame: A DataFrame with a new column for generator age.
    
Calculate and add a column for generator age.
This function calculates generator age by subtracting the year the
generator went into operation from the report year. (EIA data must be run
through date_to_year() first).

This is calculated here as opposed to in the eia860.py file because of how
the 'operating_date' is merged with the rest of the data. It seemed cleaner
to calculate the generator age here.
Calculate and add a column for generator age . This function calculates generator age by subtracting the year the generator went into operation from the report year . ( EIA data must be run through date_to_year () first ) . This is calculated here as opposed to in the eia860 . py file because of how the ' operating_date ' is merged with the rest of the data . It seemed cleaner to calculate the generator age here .
def add_generator_age(with_year_raw_eia_df):
    logger.info('Calculating generator age')
    gen_df = with_year_raw_eia_df.astype({'operating_date': 'datetime64[ns]'})
    gen_df = gen_df.assign(generator_age_years=(gen_df.report_year -
                                                gen_df.operating_date.dt.year))
    return gen_df
def add_generator_age ( with_year_raw_eia_df ) : logger . info ( 'Calculating generator age' ) gen_df = with_year_raw_eia_df . astype ( { 'operating_date' : 'datetime64[ns]' } ) gen_df = gen_df . assign ( generator_age_years = ( gen_df . report_year - gen_df . operating_date . dt . year ) ) return gen_df
Calculate and add a column for generator age.
Calculate and add a column for generator age .
"""Calculate and add a column for generator age.

    This function calculates generator age by subtracting the year the
    generator went into operation from the report year. (EIA data must be run
    through date_to_year() first).

    This is calculated here as opposed to in the eia860.py file because of how
    the 'operating_date' is merged with the rest of the data. It seemed cleaner
    to calculate the generator age here.

    Args:
        with_year_rwa_eia_df (pandas.DataFrame): A DataFrame with raw EIA data
            run through the date_to_year() function.
    Returns:
        pandas.DataFrame: A DataFrame with a new column for generator age.
    """
A DataFrame with a new column for generator age.
A DataFrame with a new column for generator age .
pandas.DataFrame
with_year_raw_eia_df
with_year_rwa_eia_df
A DataFrame with raw EIA data
run through the date_to_year() function.
A DataFrame with raw EIA data run through the date_to_year () function .