//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Standardize plant_name capitalization and remove leading/trailing white
// space -- necesary b/c plant_name is part of many foreign keys.
fuel_ferc1_df = pudl.helpers.strip_lower(fuel_ferc1_df, ["plant_name"])
// Take the messy free-form fuel & fuel_unit fields, and do our best to
// map them to some canonical categories... this is necessarily imperfect:
fuel_ferc1_df.fuel = pudl.helpers.cleanstrings(fuel_ferc1_df.fuel,
pc.ferc1_fuel_strings,
unmapped="")
fuel_ferc1_df.fuel_unit = \
pudl.helpers.cleanstrings(fuel_ferc1_df.fuel_unit,
pc.ferc1_fuel_unit_strings,
unmapped="")
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PERFORM UNIT CONVERSIONS ////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Fuel cost per kWh is a per-unit value that doesn"t make sense to report
// for a single fuel that may be only a small part of the fuel consumed.
fuel_ferc1_df.drop("fuel_cost_kwh", axis=1, inplace=True)
// This is heat rate, but as it"s based only on the heat content of a given
// fuel which may only be a small portion of the overall fuel consumption,
// it doesn"t make any sense here. Drop it.
fuel_ferc1_df.drop("fuel_generaton", axis=1, inplace=True)
// Convert from BTU/unit of fuel to 1e6 BTU/unit.
fuel_ferc1_df["fuel_avg_mmbtu_per_unit"] = fuel_ferc1_df["fuel_avg_heat"] / 1e6
fuel_ferc1_df.drop("fuel_avg_heat", axis=1, inplace=True)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// RENAME COLUMNS TO MATCH PUDL DB //////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
fuel_ferc1_df.rename(columns={
// FERC 1 DB Name PUDL DB Name
"respondent_id": "utility_id_ferc1",
"fuel": "fuel_type_code_pudl",
"fuel_avg_mmbtu_per_unit": "fuel_mmbtu_per_unit",
"fuel_quantity": "fuel_qty_burned",
"fuel_cost_burned": "fuel_cost_per_unit_burned",
"fuel_cost_delvd": "fuel_cost_per_unit_delivered",
"fuel_cost_btu": "fuel_cost_per_mmbtu"},
inplace=True)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CORRECT DATA ENTRY ERRORS //////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////