Skip to content

Commit

Permalink
Merge pull request #1671 from rmi-electricity/eia861_ba_fix
Browse files Browse the repository at this point in the history
Address issue where 861 ETL fails w/o all years of data
  • Loading branch information
zaneselvans committed Jun 8, 2022
2 parents 0ff967e + 3616eb4 commit 9562cdb
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/pudl/transform/eia861.py
Expand Up @@ -856,9 +856,23 @@ def balancing_authority(tfr_dfs):
)

# Fill in BA IDs based on date, utility ID, and BA Name:
df.loc[
BA_ID_NAME_FIXES.index, "balancing_authority_id_eia"
] = BA_ID_NAME_FIXES.balancing_authority_id_eia
# using merge and then reverse backfilling balancing_authority_id_eia means
# that this will work even if not all years are requested
df = ( # this replaces the previous process to address #828
df.merge(
BA_ID_NAME_FIXES,
on=["report_date", "balancing_authority_name_eia", "utility_id_eia"],
how="left",
validate="m:1",
suffixes=(None, "_"),
)
.assign(
balancing_authority_id_eia=lambda x: x.balancing_authority_id_eia_.fillna(
x.balancing_authority_id_eia
)
)
.drop(columns=["balancing_authority_id_eia_"])
)

# Backfill BA Codes based on BA IDs:
df = df.reset_index().pipe(_ba_code_backfill)
Expand Down

0 comments on commit 9562cdb

Please sign in to comment.