src/ei_mcoe/ei_mcoe.py
def cost_subtable_maker(ferc1_pct_df, cost_type):
    """Rearange cost breakdown data.

    A helper function for specific use within the merge_ferc_with_eia_pcts()
    function. It that takes the result of running calc_cap_op_by_fuel_ferc1()
    on newly merged eia_fuel_pcts() output and prep_plant_fuel_data_ferc1()
    (which outputs a table with ferc cost data broken down by fuel type) and
    melts it so that the fuel type columns become row values again rather than
    columns.

    This function must be executed once for every FERC value that has been
    disaggregated. (i.e. once for capex and once for opex). The two melted
    tables are later merged in the meta function merge_ferc_with_eia_pcts().

    Args:
        ferc_pct_df (pandas.DataFrame): A DataFrame with FERC Form 1 data
            disaggregated by plant and fuel type.
        cost_type (str): A string with the name of the cost column to subdivide
            by.

    Returns:
        pandas.DataFrame: A DataFrame with disaggregated FERC Form 1 data
            melted so that columns become row values.
    """
    logger.info(' -- Melting FERC pct data back to row values')
    # apply EIA fuel percents to specified FERC cost data.
    cost_df = ferc1_pct_df.rename(columns={'count_ferc1': 'ferc1_unit_count'})
    cost_df = (
        cost_df[(input_dict['plant_index_cols'] + ['ferc1_unit_count'] +
                 [cost_type + '_coal', cost_type + '_gas', cost_type + '_oil',
                  cost_type + '_waste'])]
        .rename(
            columns={cost_type + '_coal': 'coal',
                     cost_type + '_gas': 'gas',
                     cost_type + '_oil': 'oil',
                     cost_type + '_waste': 'waste'}))
    col_to_row_df = (
        pd.melt(cost_df, input_dict['plant_index_cols'] + ['ferc1_unit_count'])
        .rename(columns={'value': cost_type,
                         'variable': 'fuel_type_code_pudl'})
        .dropna(subset=[cost_type])
    )
    return col_to_row_df
Rearange cost breakdown data.

    A helper function for specific use within the merge_ferc_with_eia_pcts()
    function. It that takes the result of running calc_cap_op_by_fuel_ferc1()
    on newly merged eia_fuel_pcts() output and prep_plant_fuel_data_ferc1()
    (which outputs a table with ferc cost data broken down by fuel type) and
    melts it so that the fuel type columns become row values again rather than
    columns.

    This function must be executed once for every FERC value that has been
    disaggregated. (i.e. once for capex and once for opex). The two melted
    tables are later merged in the meta function merge_ferc_with_eia_pcts().

    Args:
        ferc_pct_df (pandas.DataFrame): A DataFrame with FERC Form 1 data
            disaggregated by plant and fuel type.
        cost_type (str): A string with the name of the cost column to subdivide
            by.

    Returns:
        pandas.DataFrame: A DataFrame with disaggregated FERC Form 1 data
            melted so that columns become row values.
    
Rearange cost breakdown data.
A helper function for specific use within the merge_ferc_with_eia_pcts()
function. It that takes the result of running calc_cap_op_by_fuel_ferc1()
on newly merged eia_fuel_pcts() output and prep_plant_fuel_data_ferc1()
(which outputs a table with ferc cost data broken down by fuel type) and
melts it so that the fuel type columns become row values again rather than
columns.

This function must be executed once for every FERC value that has been
disaggregated.
Rearange cost breakdown data . A helper function for specific use within the merge_ferc_with_eia_pcts () function . It that takes the result of running calc_cap_op_by_fuel_ferc1 () on newly merged eia_fuel_pcts () output and prep_plant_fuel_data_ferc1 () ( which outputs a table with ferc cost data broken down by fuel type ) and melts it so that the fuel type columns become row values again rather than columns . This function must be executed once for every FERC value that has been disaggregated .
def cost_subtable_maker(ferc1_pct_df, cost_type):
    logger.info(' -- Melting FERC pct data back to row values')
    cost_df = ferc1_pct_df.rename(columns={'count_ferc1': 'ferc1_unit_count'})
    cost_df = (
        cost_df[(input_dict['plant_index_cols'] + ['ferc1_unit_count'] +
                 [cost_type + '_coal', cost_type + '_gas', cost_type + '_oil',
                  cost_type + '_waste'])]
        .rename(
            columns={cost_type + '_coal': 'coal',
                     cost_type + '_gas': 'gas',
                     cost_type + '_oil': 'oil',
                     cost_type + '_waste': 'waste'}))
    col_to_row_df = (
        pd.melt(cost_df, input_dict['plant_index_cols'] + ['ferc1_unit_count'])
        .rename(columns={'value': cost_type,
                         'variable': 'fuel_type_code_pudl'})
        .dropna(subset=[cost_type])
    )
    return col_to_row_df
def cost_subtable_maker ( ferc1_pct_df , cost_type ) : logger . info ( ' -- Melting FERC pct data back to row values' ) cost_df = ferc1_pct_df . rename ( columns = { 'count_ferc1' : 'ferc1_unit_count' } ) cost_df = ( cost_df [ ( input_dict [ 'plant_index_cols' ] + [ 'ferc1_unit_count' ] + [ cost_type + '_coal' , cost_type + '_gas' , cost_type + '_oil' , cost_type + '_waste' ] ) ] . rename ( columns = { cost_type + '_coal' : 'coal' , cost_type + '_gas' : 'gas' , cost_type + '_oil' : 'oil' , cost_type + '_waste' : 'waste' } ) ) col_to_row_df = ( pd . melt ( cost_df , input_dict [ 'plant_index_cols' ] + [ 'ferc1_unit_count' ] ) . rename ( columns = { 'value' : cost_type , 'variable' : 'fuel_type_code_pudl' } ) . dropna ( subset = [ cost_type ] ) ) return col_to_row_df
Rearange cost breakdown data.
Rearange cost breakdown data .
"""Rearange cost breakdown data.

    A helper function for specific use within the merge_ferc_with_eia_pcts()
    function. It that takes the result of running calc_cap_op_by_fuel_ferc1()
    on newly merged eia_fuel_pcts() output and prep_plant_fuel_data_ferc1()
    (which outputs a table with ferc cost data broken down by fuel type) and
    melts it so that the fuel type columns become row values again rather than
    columns.

    This function must be executed once for every FERC value that has been
    disaggregated. (i.e. once for capex and once for opex). The two melted
    tables are later merged in the meta function merge_ferc_with_eia_pcts().

    Args:
        ferc_pct_df (pandas.DataFrame): A DataFrame with FERC Form 1 data
            disaggregated by plant and fuel type.
        cost_type (str): A string with the name of the cost column to subdivide
            by.

    Returns:
        pandas.DataFrame: A DataFrame with disaggregated FERC Form 1 data
            melted so that columns become row values.
    """ # apply EIA fuel percents to specified FERC cost data.
A DataFrame with disaggregated FERC Form 1 data
melted so that columns become row values.
A DataFrame with disaggregated FERC Form 1 data melted so that columns become row values .
pandas.DataFrame
ferc1_pct_df
cost_type
A string with the name of the cost column to subdivide
by.
A string with the name of the cost column to subdivide by .
ferc_pct_df
A DataFrame with FERC Form 1 data
disaggregated by plant and fuel type.
A DataFrame with FERC Form 1 data disaggregated by plant and fuel type .