a5d1cf98f0ec5c72fb48336cafaf31bf11e6128e,src/pudl/analysis/mcoe.py,,mcoe,#Any#Any#Any#Any#Any#,311

Before Change


        mcoe_out = mcoe_out[mcoe_out.heat_rate_mmbtu_mwh >= min_heat_rate]
    if min_fuel_cost_per_mwh is not None:
        mcoe_out = mcoe_out[mcoe_out.fuel_cost_per_mwh > min_fuel_cost_per_mwh]
    if min_cap_fact is not None:
        mcoe_out = mcoe_out[mcoe_out.capacity_factor >= min_cap_fact]
    if max_cap_fact is not None:
        mcoe_out = mcoe_out[mcoe_out.capacity_factor <= max_cap_fact]

    return mcoe_out

After Change


                 if x in pudl_out.fuel_cost().columns and x not in merge_cols]
    // start with the generators table so we have all of the generators
    mcoe_out = pudl.helpers.merge_on_date_year(
        pudl_out.fuel_cost().drop(drop_cols, axis=1),
        pudl_out.gens_eia860(),
        on=[x for x in merge_cols if x != "report_date"],
        how="inner",
    )
    // Bring together the fuel cost and capacity factor dataframes, which
    // also include heat rate information.
    mcoe_out = pd.merge(
        mcoe_out,
        pudl_out.capacity_factor(min_cap_fact=min_cap_fact,
                                 max_cap_fact=max_cap_fact)[
            ["report_date", "plant_id_eia",
             "generator_id", "capacity_factor", "net_generation_mwh"]],
        on=["report_date", "plant_id_eia", "generator_id"],
        how="outer")

    // Bring the PUDL Unit IDs into the output dataframe so we can see how
    // the generators are really grouped.
    mcoe_out = pudl.helpers.merge_on_date_year(
        mcoe_out,
        pudl_out.bga()[["report_date",
                        "plant_id_eia",
                        "unit_id_pudl",
                        "generator_id"]].drop_duplicates(),
        how="left",
        on=["plant_id_eia", "generator_id"])
    // Instead of getting the total MMBTU through this multiplication... we
    // could also calculate the total fuel consumed on a per-unit basis, from
    // the boiler_fuel table, and then determine what proportion should be
    // distributed to each generator based on its heat-rate and net generation.
    mcoe_out["total_mmbtu"] = \
        mcoe_out.net_generation_mwh * mcoe_out.heat_rate_mmbtu_mwh
    mcoe_out["total_fuel_cost"] = \
        mcoe_out.total_mmbtu * mcoe_out.fuel_cost_per_mmbtu

    first_cols = ["report_date",
                  "plant_id_eia",
                  "plant_id_pudl",
                  "unit_id_pudl",
                  "generator_id",
                  "plant_name_eia",
                  "utility_id_eia",
                  "utility_id_pudl",
                  "utility_name_eia"]
    mcoe_out = pudl.helpers.organize_cols(mcoe_out, first_cols)
    mcoe_out = mcoe_out.sort_values(
        ["plant_id_eia", "unit_id_pudl", "generator_id", "report_date"]
    )

    // Filter the output based on the range of validity supplied by the user:
    mcoe_out = pudl.helpers.oob_to_nan(mcoe_out, ["heat_rate_mmbtu_mwh"],
                                       lb=min_heat_rate, ub=None)
    mcoe_out = pudl.helpers.oob_to_nan(mcoe_out, ["fuel_cost_per_mwh"],
                                       lb=min_fuel_cost_per_mwh, ub=None)
    mcoe_out = pudl.helpers.oob_to_nan(mcoe_out, ["capacity_factor"],
                                       lb=min_cap_fact, ub=max_cap_fact)
    return mcoe_out
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: catalyst-cooperative/pudl
Commit Name: a5d1cf98f0ec5c72fb48336cafaf31bf11e6128e
Time: 2020-05-16
Author: cgosnell@catalyst.coop
File Name: src/pudl/analysis/mcoe.py
Class Name:
Method Name: mcoe


Project Name: CNuge/kaggle-code
Commit Name: b7990885d8b26b9404fd9ce952b0b2f005019594
Time: 2018-01-12
Author: nugentc@uoguelph.ca
File Name: california_housing/feature_engineering.py
Class Name:
Method Name:


Project Name: kwgoodman/numerox
Commit Name: 7697dc84cdc2d0ba5e28227d15f166d6a569bd95
Time: 2018-06-25
Author: kwgoodman@gmail.com
File Name: numerox/numerai.py
Class Name:
Method Name: get_stakes