Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix validation test_fbp_ferc1_mismatched_fuels error #3025

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/pudl/analysis/classify_plants_ferc1.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,9 +654,11 @@ def fuel_by_plant_ferc1(
]

# Ensure that the dataframe we've gotten has all the information we need:
for col in keep_cols:
if col not in fuel_df.columns:
raise AssertionError(f"Required column {col} not found in input fuel_df.")
missing_cols = [col for col in keep_cols if col not in fuel_df.columns]
if missing_cols:
raise AssertionError(
f"Required columns not found in input fuel_df: {missing_cols}"
)

# Calculate per-fuel derived values and add them to the DataFrame
df = (
Expand All @@ -679,7 +681,8 @@ def fuel_by_plant_ferc1(
"plant_name_ferc1",
"report_year",
"fuel_type_code_pudl",
]
],
observed=True,
zaneselvans marked this conversation as resolved.
Show resolved Hide resolved
)
.sum()
.reset_index()
Expand Down Expand Up @@ -732,6 +735,7 @@ def fuel_by_plant_ferc1(
).reset_index()

# Label each plant-year record by primary fuel:
df.loc[:, ["primary_fuel_by_cost", "primary_fuel_by_mmbtu"]] = pd.NA
zaneselvans marked this conversation as resolved.
Show resolved Hide resolved
for fuel_str in fuel_categories:
try:
mmbtu_mask = df[f"{fuel_str}_fraction_mmbtu"] > thresh
Expand Down
4 changes: 0 additions & 4 deletions src/pudl/output/ferc1.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,6 @@ def drop_other_fuel_types(df):
return df[df.fuel_type_code_pudl != "other"].copy()

thresh = context.op_config["thresh"]
# The existing function expects `fuel_type_code_pudl` to be an object, rather than
# a category. This is a legacy of pre-dagster code, and we convert here to prevent
# further retooling in the code-base.
fuel_ferc1["fuel_type_code_pudl"] = fuel_ferc1["fuel_type_code_pudl"].astype(str)

fuel_categories = list(
pudl.transform.ferc1.FuelFerc1TableTransformer()
Expand Down