patio.data.entity_ids¶
Attributes¶
Functions¶
|
Add respondent and final ba_codes. |
|
Process for assigning plants to EIA BA codes and FERC 1 Respondent IDs. |
Module Contents¶
- patio.data.entity_ids.RESPS_TO_KEEP = (130, 177, 186, 195, 210, 22, 531, 552, 556, 58, 656, 658)[source]¶
- patio.data.entity_ids.add_ba_code(input_df, new_ba_col='final_ba_code', *, ba_rollup_only=False, drop_interim=False, apply_purchaser=True)[source]¶
Add respondent and final ba_codes.
Steps if
ba_rollup_only
is False. If it is True, we simply apply theBA_REPLACE
map tobalancing_authority_code_eia
. 1. First we read in UTH utility information which associatesutility_id_eia
to FERC
respondent_id
. In that dataset we grab those two columns, drop rows where either is null and remove duplicates. For the next step it is critical that a givenutility_id_eia
map to one and only onerespondent_id
, though multipleutility_id_eia
can map to single arespondent_id
.We then merge the result of (1) onto the incoming
pandas.DataFrame
[Optional if applying purchaser data] Read in UTH purchased power data, select only purchase data from 2020 (the last manually tagged year) where
plant_id_eia
is not null, i.e. cases where the purchased power tagging found a plant-level match. This data will allow us to associateplant_id_eia
with therespondent_id
that purchases its power. To make this unique we require that therespondent_id
purchases ≥90% of power that the plant sells (NOTE: this is not as a % of the total plant generation, just that plant’s sales that we have identified in the purchase power tagging process). We then merge this onto the result of (2) onplant_id_eia
. The resultingfinal_respondent_id
for aplant_id_eia
only uses therespondent_id_purchaser
if thatplant_id_eia
did not have arespondent_id
assigned in step (2).The final step is to adjust the final ba codes using
adjust_ba_codes()
. This process attempts to group the rows ofinput_df
into planning areas by doing one of the following:Using the
final_respondent_id
irrespective of a given row’sbalancing_authority_code_eia
.Using the
balancing_authority_code_eia
irrespective of a given row’sfinal_respondent_id
.
Combining one or more
balancing_authority_code_eia
into a single new region.Doing something more complicated (see
adjust_ba_codes()
body for the 8 special cases).
- Parameters:
input_df (pandas.DataFrame) – frame to add BA / respondent columns to
new_ba_col (str) – name of ultimate BA code column
ba_rollup_only (bool) – if True, we only rollup EIA BA codes using
BA_REPLACE
drop_interim (bool) – if True, drop all the intermediate respondent / BA code columns
apply_purchaser (bool) – if True, change respondent to respondent of purchaser, requires plant_id_eia
Returns:
- patio.data.entity_ids.adjust_ba_codes(df, new_ba_col='final_ba_code')[source]¶
Process for assigning plants to EIA BA codes and FERC 1 Respondent IDs.
- Parameters:
df (pandas.DataFrame)
- Return type: