src/ei_mcoe/ei_mcoe.py
def compare_ferc_eia(pudl_out):
    """Gather FERC, EIA Data; create compatible DataFrames; merge.

    Args:
        pudl_out (pudl.output.pudltabl.PudlTabl): An object used to create
            the tables used for EIA and FERC analysis.

    Returns:
        pandas.DataFrame: A DataFrame with merged FERC Form 1 and EIA data at
            the plant level. For use in graphic comparison.
    """
    steam_ferc1 = pudl_out.plants_steam_ferc1()
    mcoe = pudl_out.mcoe()
    nf = pudl.transform.ferc1.fuel_by_plant_ferc1(pudl_out.fuel_ferc1())
    key_cols = [
        'report_year',
        'utility_id_ferc1',
        'plant_name_ferc1']
    ferc1_plants = (
        pd.merge(nf, steam_ferc1, on=key_cols, how='inner')
        .assign(heat_rate_mmbtu_mwh=lambda x: (x.fuel_mmbtu /
                                               x.net_generation_mwh))
        .merge(steam_ferc1[key_cols + ['utility_id_pudl', 'utility_name_ferc1',
                                       'plant_id_pudl', 'plant_id_ferc1']])
        .rename(columns={'fuel_mmbtu': 'total_mmbtu'}))
    eia_plants = (
        mcoe.assign(report_year=lambda x: x.report_date.dt.year)
        .rename(columns={'total_fuel_cost': 'opex_fuel',
                         'fuel_type_code_pudl': 'primary_fuel_by_mmbtu'}))
    pudl_plant_cols = [
        'plant_id_pudl',
        'primary_fuel_by_mmbtu',
        'report_year']
    # Create comprable dfs
    eia_df = create_compatible_df(eia_plants, pudl_plant_cols)
    ferc1_df = create_compatible_df(ferc1_plants, pudl_plant_cols)
    # Merge dfs
    eia_ferc1_merge = pd.merge(ferc1_df, eia_df, suffixes=('_ferc1', '_eia'),
                               on=pudl_plant_cols, how='inner')
    return eia_ferc1_merge
Gather FERC, EIA Data; create compatible DataFrames; merge.

    Args:
        pudl_out (pudl.output.pudltabl.PudlTabl): An object used to create
            the tables used for EIA and FERC analysis.

    Returns:
        pandas.DataFrame: A DataFrame with merged FERC Form 1 and EIA data at
            the plant level. For use in graphic comparison.
    
Gather FERC, EIA Data; create compatible DataFrames; merge.
Gather FERC EIA Data ; create compatible DataFrames ; merge .
def compare_ferc_eia(pudl_out):
    steam_ferc1 = pudl_out.plants_steam_ferc1()
    mcoe = pudl_out.mcoe()
    nf = pudl.transform.ferc1.fuel_by_plant_ferc1(pudl_out.fuel_ferc1())
    key_cols = [
        'report_year',
        'utility_id_ferc1',
        'plant_name_ferc1']
    ferc1_plants = (
        pd.merge(nf, steam_ferc1, on=key_cols, how='inner')
        .assign(heat_rate_mmbtu_mwh=lambda x: (x.fuel_mmbtu /
                                               x.net_generation_mwh))
        .merge(steam_ferc1[key_cols + ['utility_id_pudl', 'utility_name_ferc1',
                                       'plant_id_pudl', 'plant_id_ferc1']])
        .rename(columns={'fuel_mmbtu': 'total_mmbtu'}))
    eia_plants = (
        mcoe.assign(report_year=lambda x: x.report_date.dt.year)
        .rename(columns={'total_fuel_cost': 'opex_fuel',
                         'fuel_type_code_pudl': 'primary_fuel_by_mmbtu'}))
    pudl_plant_cols = [
        'plant_id_pudl',
        'primary_fuel_by_mmbtu',
        'report_year']
    eia_df = create_compatible_df(eia_plants, pudl_plant_cols)
    ferc1_df = create_compatible_df(ferc1_plants, pudl_plant_cols)
    eia_ferc1_merge = pd.merge(ferc1_df, eia_df, suffixes=('_ferc1', '_eia'),
                               on=pudl_plant_cols, how='inner')
    return eia_ferc1_merge
def compare_ferc_eia ( pudl_out ) : steam_ferc1 = pudl_out . plants_steam_ferc1 ( ) mcoe = pudl_out . mcoe ( ) nf = pudl . transform . ferc1 . fuel_by_plant_ferc1 ( pudl_out . fuel_ferc1 ( ) ) key_cols = [ 'report_year' , 'utility_id_ferc1' , 'plant_name_ferc1' ] ferc1_plants = ( pd . merge ( nf , steam_ferc1 , on = key_cols , how = 'inner' ) . assign ( heat_rate_mmbtu_mwh = lambda x : ( x . fuel_mmbtu / x . net_generation_mwh ) ) . merge ( steam_ferc1 [ key_cols + [ 'utility_id_pudl' , 'utility_name_ferc1' , 'plant_id_pudl' , 'plant_id_ferc1' ] ] ) . rename ( columns = { 'fuel_mmbtu' : 'total_mmbtu' } ) ) eia_plants = ( mcoe . assign ( report_year = lambda x : x . report_date . dt . year ) . rename ( columns = { 'total_fuel_cost' : 'opex_fuel' , 'fuel_type_code_pudl' : 'primary_fuel_by_mmbtu' } ) ) pudl_plant_cols = [ 'plant_id_pudl' , 'primary_fuel_by_mmbtu' , 'report_year' ] eia_df = create_compatible_df ( eia_plants , pudl_plant_cols ) ferc1_df = create_compatible_df ( ferc1_plants , pudl_plant_cols ) eia_ferc1_merge = pd . merge ( ferc1_df , eia_df , suffixes = ( '_ferc1' , '_eia' ) , on = pudl_plant_cols , how = 'inner' ) return eia_ferc1_merge
Gather FERC, EIA Data; create compatible DataFrames; merge.
Gather FERC EIA Data ; create compatible DataFrames ; merge .
"""Gather FERC, EIA Data; create compatible DataFrames; merge.

    Args:
        pudl_out (pudl.output.pudltabl.PudlTabl): An object used to create
            the tables used for EIA and FERC analysis.

    Returns:
        pandas.DataFrame: A DataFrame with merged FERC Form 1 and EIA data at
            the plant level. For use in graphic comparison.
    """ # Create comprable dfs # Merge dfs
A DataFrame with merged FERC Form 1 and EIA data at
the plant level. For use in graphic comparison.
A DataFrame with merged FERC Form 1 and EIA data at the plant level . For use in graphic comparison .
pandas.DataFrame
pudl_out
An object used to create
the tables used for EIA and FERC analysis.
An object used to create the tables used for EIA and FERC analysis .