src/ei_mcoe/ei_mcoe.py
def compile_fuel_pcts_eia(raw_eia_df):
    """Extract EIA's fuel type percents to map onto FERC Form 1 data.

    This function pulls together the outputs of functions calc_fuel_pcts_eia()
    (which itself calls eia_pct_df_maker()) to create an output DataFrame with
    EIA data aggregated by level with columns indicating the percent that each
    fuel type contribues to the total capacity and net generation.

    This data is now staged for a merge with FERC Form 1 data so that its cost
    values can be multiplied by the EIA fuel percentages and so disaggreated by
    the specified level.

    Args:
        raw_eia_df (pandas.DataFrame): A DataFrame containing EIA data from the
            pudl_out.mcoe() function that has been run through the prep_raw_
            eia() function.

    Returns:
        pandas.DataFrame: A DataFrame with columns for capacity
            and net generation for each fuel type at the plant or unit level.
    """
    logger.info(' - Readying EIA fuel pct data to merge with FERC')
    # Create df with the plant level totals (combines fuel types) for the
    # aggregated mcoe data.
    eia_plant_df = (
        raw_eia_df.groupby(input_dict['plant_index_cols'], as_index=False)
        [input_dict['eia_sum_cols']]
        .sum(min_count=1))
    # Create df with the plant-fuel level totals
    eia_plant_fuel_df = prep_plant_fuel_data_eia(raw_eia_df)
    # Merge with fuel type totals for df with plant totals and fuel totals
    merge_df = (
        pd.merge(eia_plant_df, eia_plant_fuel_df,
                 on=input_dict['plant_index_cols'], how='outer',
                 suffixes=['_plant_level', '_fuel_level'])
        .drop_duplicates())
    # Calculate the percentage that each fuel type (coal, oil, gas, waste)
    # accounts for for the specified columns (net gen & capacity)
    # **NOTE** cannot feed this function a list of col names beacuse merge
    # function does not take a list.
    eia_pct_df = (
        calc_fuel_pcts_eia(
            merge_df, 'net_generation_mwh', 'capacity_mw'))
    # Return table needed for ferc fuel type delineation and final FERC1 merge.
    return eia_pct_df
Extract EIA's fuel type percents to map onto FERC Form 1 data.

    This function pulls together the outputs of functions calc_fuel_pcts_eia()
    (which itself calls eia_pct_df_maker()) to create an output DataFrame with
    EIA data aggregated by level with columns indicating the percent that each
    fuel type contribues to the total capacity and net generation.

    This data is now staged for a merge with FERC Form 1 data so that its cost
    values can be multiplied by the EIA fuel percentages and so disaggreated by
    the specified level.

    Args:
        raw_eia_df (pandas.DataFrame): A DataFrame containing EIA data from the
            pudl_out.mcoe() function that has been run through the prep_raw_
            eia() function.

    Returns:
        pandas.DataFrame: A DataFrame with columns for capacity
            and net generation for each fuel type at the plant or unit level.
    
Extract EIA's fuel type percents to map onto FERC Form 1 data.
This function pulls together the outputs of functions calc_fuel_pcts_eia()
(which itself calls eia_pct_df_maker()) to create an output DataFrame with
EIA data aggregated by level with columns indicating the percent that each
fuel type contribues to the total capacity and net generation.

This data is now staged for a merge with FERC Form 1 data so that its cost
values can be multiplied by the EIA fuel percentages and so disaggreated by
the specified level.
Extract EIA ' s fuel type percents to map onto FERC Form 1 data . This function pulls together the outputs of functions calc_fuel_pcts_eia () ( which itself calls eia_pct_df_maker () ) to create an output DataFrame with EIA data aggregated by level with columns indicating the percent that each fuel type contribues to the total capacity and net generation . This data is now staged for a merge with FERC Form 1 data so that its cost values can be multiplied by the EIA fuel percentages and so disaggreated by the specified level .
def compile_fuel_pcts_eia(raw_eia_df):
    logger.info(' - Readying EIA fuel pct data to merge with FERC')
    eia_plant_df = (
        raw_eia_df.groupby(input_dict['plant_index_cols'], as_index=False)
        [input_dict['eia_sum_cols']]
        .sum(min_count=1))
    eia_plant_fuel_df = prep_plant_fuel_data_eia(raw_eia_df)
    merge_df = (
        pd.merge(eia_plant_df, eia_plant_fuel_df,
                 on=input_dict['plant_index_cols'], how='outer',
                 suffixes=['_plant_level', '_fuel_level'])
        .drop_duplicates())
    eia_pct_df = (
        calc_fuel_pcts_eia(
            merge_df, 'net_generation_mwh', 'capacity_mw'))
    return eia_pct_df
def compile_fuel_pcts_eia ( raw_eia_df ) : logger . info ( ' - Readying EIA fuel pct data to merge with FERC' ) eia_plant_df = ( raw_eia_df . groupby ( input_dict [ 'plant_index_cols' ] , as_index = False ) [ input_dict [ 'eia_sum_cols' ] ] . sum ( min_count = 1 ) ) eia_plant_fuel_df = prep_plant_fuel_data_eia ( raw_eia_df ) merge_df = ( pd . merge ( eia_plant_df , eia_plant_fuel_df , on = input_dict [ 'plant_index_cols' ] , how = 'outer' , suffixes = [ '_plant_level' , '_fuel_level' ] ) . drop_duplicates ( ) ) eia_pct_df = ( calc_fuel_pcts_eia ( merge_df , 'net_generation_mwh' , 'capacity_mw' ) ) return eia_pct_df
Extract EIA's fuel type percents to map onto FERC Form 1 data.
Extract EIA ' s fuel type percents to map onto FERC Form 1 data .
"""Extract EIA's fuel type percents to map onto FERC Form 1 data.

    This function pulls together the outputs of functions calc_fuel_pcts_eia()
    (which itself calls eia_pct_df_maker()) to create an output DataFrame with
    EIA data aggregated by level with columns indicating the percent that each
    fuel type contribues to the total capacity and net generation.

    This data is now staged for a merge with FERC Form 1 data so that its cost
    values can be multiplied by the EIA fuel percentages and so disaggreated by
    the specified level.

    Args:
        raw_eia_df (pandas.DataFrame): A DataFrame containing EIA data from the
            pudl_out.mcoe() function that has been run through the prep_raw_
            eia() function.

    Returns:
        pandas.DataFrame: A DataFrame with columns for capacity
            and net generation for each fuel type at the plant or unit level.
    """ # Create df with the plant level totals (combines fuel types) for the # aggregated mcoe data. # Create df with the plant-fuel level totals # Merge with fuel type totals for df with plant totals and fuel totals # Calculate the percentage that each fuel type (coal, oil, gas, waste) # accounts for for the specified columns (net gen & capacity) # **NOTE** cannot feed this function a list of col names beacuse merge # function does not take a list. # Return table needed for ferc fuel type delineation and final FERC1 merge.
A DataFrame with columns for capacity
and net generation for each fuel type at the plant or unit level.
A DataFrame with columns for capacity and net generation for each fuel type at the plant or unit level .
pandas.DataFrame
raw_eia_df
A DataFrame containing EIA data from the
pudl_out.mcoe() function that has been run through the prep_raw_
eia() function.
A DataFrame containing EIA data from the pudl_out . mcoe () function that has been run through the prep_raw_ eia () function .