src/ei_mcoe/ei_mcoe.py
def prep_raw_eia(pudl_out):
    """Add generator age and report year column to raw eia data.

    This acts as the singular function needed to prep the raw EIA data. Any
    functions needing this "cleaned" or "prepped" raw data will refer to it as
    raw_eia_df.

    Args:
        pudl_out (pudl.output.pudltabl.PudlTabl): An object used to create
            the tables for EIA and FERC Form 1 analysis.
    Returns:
        pandas.DataFrame: A DataFrame containing raw EIA data with a column for
            generator age and a column for report year.
    """
    logger.info('Prepping raw EIA data')
    idx_gens = ['report_date', 'plant_id_eia', 'generator_id']
    cols_mcoe = [
        col for col in pudl_out.mcoe() if col not in pudl_out.gens_eia860()
    ]
    raw_eia = (
        pd.merge(
            pudl_out.gens_eia860().astype({'plant_id_eia': 'Int64'}),
            pudl_out.mcoe()[idx_gens +
                            cols_mcoe].astype({'plant_id_eia': 'Int64'}),
            how='outer',
            on=idx_gens,
            indicator=True
        )
        .merge(
            pudl_out.plants_eia860().astype({'plant_id_eia': 'Int64'})[
                ['report_date', 'plant_id_eia', 'nerc_region']],
            on=['report_date', 'plant_id_eia'],
            how='left',
            validate='m:1'
        )
    )
    if len(raw_eia[raw_eia._merge == 'right_only']):
        warnings.warn(len(raw_eia[raw_eia._merge == 'right_only']))
    raw_eia = (raw_eia.loc[raw_eia.operational_status != 'retired']
               .loc[raw_eia.plant_id_pudl.notnull()]
               .drop(columns='_merge')
               .pipe(date_to_year)
               .pipe(add_generator_age)
               # .pipe(eliminate_retired_plants)
               # .pipe(add_var_cost_col)
               )
    return raw_eia
Add generator age and report year column to raw eia data.

    This acts as the singular function needed to prep the raw EIA data. Any
    functions needing this "cleaned" or "prepped" raw data will refer to it as
    raw_eia_df.

    Args:
        pudl_out (pudl.output.pudltabl.PudlTabl): An object used to create
            the tables for EIA and FERC Form 1 analysis.
    Returns:
        pandas.DataFrame: A DataFrame containing raw EIA data with a column for
            generator age and a column for report year.
    
Add generator age and report year column to raw eia data.
This acts as the singular function needed to prep the raw EIA data. Any
functions needing this "cleaned" or "prepped" raw data will refer to it as
raw_eia_df.
Add generator age and report year column to raw eia data . This acts as the singular function needed to prep the raw EIA data . Any functions needing this " cleaned " or " prepped " raw data will refer to it as raw_eia_df .
def prep_raw_eia(pudl_out):
    logger.info('Prepping raw EIA data')
    idx_gens = ['report_date', 'plant_id_eia', 'generator_id']
    cols_mcoe = [
        col for col in pudl_out.mcoe() if col not in pudl_out.gens_eia860()
    ]
    raw_eia = (
        pd.merge(
            pudl_out.gens_eia860().astype({'plant_id_eia': 'Int64'}),
            pudl_out.mcoe()[idx_gens +
                            cols_mcoe].astype({'plant_id_eia': 'Int64'}),
            how='outer',
            on=idx_gens,
            indicator=True
        )
        .merge(
            pudl_out.plants_eia860().astype({'plant_id_eia': 'Int64'})[
                ['report_date', 'plant_id_eia', 'nerc_region']],
            on=['report_date', 'plant_id_eia'],
            how='left',
            validate='m:1'
        )
    )
    if len(raw_eia[raw_eia._merge == 'right_only']):
        warnings.warn(len(raw_eia[raw_eia._merge == 'right_only']))
    raw_eia = (raw_eia.loc[raw_eia.operational_status != 'retired']
               .loc[raw_eia.plant_id_pudl.notnull()]
               .drop(columns='_merge')
               .pipe(date_to_year)
               .pipe(add_generator_age)
               )
    return raw_eia
def prep_raw_eia ( pudl_out ) : logger . info ( 'Prepping raw EIA data' ) idx_gens = [ 'report_date' , 'plant_id_eia' , 'generator_id' ] cols_mcoe = [ col for col in pudl_out . mcoe ( ) if col not in pudl_out . gens_eia860 ( ) ] raw_eia = ( pd . merge ( pudl_out . gens_eia860 ( ) . astype ( { 'plant_id_eia' : 'Int64' } ) , pudl_out . mcoe ( ) [ idx_gens + cols_mcoe ] . astype ( { 'plant_id_eia' : 'Int64' } ) , how = 'outer' , on = idx_gens , indicator = True ) . merge ( pudl_out . plants_eia860 ( ) . astype ( { 'plant_id_eia' : 'Int64' } ) [ [ 'report_date' , 'plant_id_eia' , 'nerc_region' ] ] , on = [ 'report_date' , 'plant_id_eia' ] , how = 'left' , validate = 'm:1' ) ) if len ( raw_eia [ raw_eia . _merge == 'right_only' ] ) : warnings . warn ( len ( raw_eia [ raw_eia . _merge == 'right_only' ] ) ) raw_eia = ( raw_eia . loc [ raw_eia . operational_status != 'retired' ] . loc [ raw_eia . plant_id_pudl . notnull ( ) ] . drop ( columns = '_merge' ) . pipe ( date_to_year ) . pipe ( add_generator_age ) ) return raw_eia
Add generator age and report year column to raw eia data.
Add generator age and report year column to raw eia data .
"""Add generator age and report year column to raw eia data.

    This acts as the singular function needed to prep the raw EIA data. Any
    functions needing this "cleaned" or "prepped" raw data will refer to it as
    raw_eia_df.

    Args:
        pudl_out (pudl.output.pudltabl.PudlTabl): An object used to create
            the tables for EIA and FERC Form 1 analysis.
    Returns:
        pandas.DataFrame: A DataFrame containing raw EIA data with a column for
            generator age and a column for report year.
    """ # .pipe(eliminate_retired_plants) # .pipe(add_var_cost_col)
A DataFrame containing raw EIA data with a column for
generator age and a column for report year.
A DataFrame containing raw EIA data with a column for generator age and a column for report year .
pandas.DataFrame
pudl_out
An object used to create
the tables for EIA and FERC Form 1 analysis.
An object used to create the tables for EIA and FERC Form 1 analysis .