o_df = eia860_dfs["ownership"].copy()
// Replace "." and " " with NaN in order to read in integer values
o_df = pudl.helpers.fix_eia_na(o_df)
o_df = pudl.helpers.convert_to_date(o_df)
// The fix we"re making here is only known to be valid for 2011 -- if we
// get older data... then we need to to revisit the cleaning function and
// make sure it also applies to those earlier years.
if min(o_df.report_date.dt.year) < min(pc.working_years["eia860"]):
raise ValueError(
f"EIA 860 transform step is only known to work for "
f"year {min(pc.working_years["eia860"])} and later, but found data "
f"from year {min(o_df.report_date.dt.year)}."
)
// Prior to 2012, ownership was reported as a percentage, rather than
// as a proportion, so we need to divide those values by 100.
o_df.loc[o_df.report_date.dt.year == 2011, "fraction_owned"] = \
o_df.loc[o_df.report_date.dt.year == 2011, "fraction_owned"] / 100
o_df["owner_utility_id_eia"] = o_df["owner_utility_id_eia"].astype(int)
o_df["utility_id_eia"] = o_df["utility_id_eia"].astype(int)
o_df["plant_id_eia"] = o_df["plant_id_eia"].astype(int)
eia860_transformed_dfs["ownership_eia860"] = o_df
return eia860_transformed_dfs
After Change
DataFrames of values from that page (values)
o_df = (
eia860_dfs["ownership"].copy()
.pipe(pudl.helpers.fix_eia_na)
.pipe(pudl.helpers.convert_to_date)
)
// The fix we"re making here is only known to be valid for 2011 -- if we
// get older data... then we need to to revisit the cleaning function and
// make sure it also applies to those earlier years.
if min(o_df.report_date.dt.year) < min(pc.working_years["eia860"]):
raise ValueError(
f"EIA 860 transform step is only known to work for "
f"year {min(pc.working_years["eia860"])} and later, but found data "
f"from year {min(o_df.report_date.dt.year)}."
)
// Prior to 2012, ownership was reported as a percentage, rather than
// as a proportion, so we need to divide those values by 100.
o_df.loc[o_df.report_date.dt.year == 2011, "fraction_owned"] = \
o_df.loc[o_df.report_date.dt.year == 2011, "fraction_owned"] / 100
o_df["owner_utility_id_eia"] = o_df["owner_utility_id_eia"].astype(int)
o_df["utility_id_eia"] = o_df["utility_id_eia"].astype(int)
o_df["plant_id_eia"] = o_df["plant_id_eia"].astype(int)
eia860_transformed_dfs["ownership_eia860"] = o_df
return eia860_transformed_dfs