Skip to content

Commit

Permalink
Fix bug with non-numeric data for agg function
Browse files Browse the repository at this point in the history
  • Loading branch information
mfleschutz committed May 22, 2024
1 parent c78dab8 commit 82b5677
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions elmada/from_opsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,7 @@ def get_CEFs_from_merit_order(
total_load_T = from_entsoe.load_el_national_generation(
year=year, freq=freq, country=country
).sum(axis=1)
cols = [
"cumsum_capa",
"marginal_emissions",
"capa",
"fuel_draf",
"used_eff",
"marginal_cost",
]
cols = ["cumsum_capa", "marginal_emissions", "capa", "fuel_draf", "used_eff", "marginal_cost"]
len_mo = len(mo_P)
mo_P_arr = mo_P[cols].values
transm_eff = from_other.get_transmission_efficiency(country=country)
Expand Down Expand Up @@ -132,8 +125,8 @@ def get_summary(year=2019) -> pd.DataFrame:
grouper = ca.groupby(["fuel", "technology"])
d = dict(
counts=grouper.count().id,
efficiency=grouper.mean()["efficiency_estimate"],
sum_capa=grouper.sum()["capacity_net_bnetza"],
efficiency=grouper["efficiency_estimate"].mean(),
sum_capa=grouper["capacity_net_bnetza"].sum(),
)
return pd.concat(d.values(), axis=1, keys=d.keys())

Expand Down Expand Up @@ -224,8 +217,7 @@ def _preprocess_efficiencies(
ensure_minimum_efficiency: bool = True,
minimum_efficiency: float = 0.3,
) -> pd.DataFrame:

filler_dic = df.groupby(by="fuel_draf").mean()["efficiency_estimate"].to_dict()
filler_dic = df.groupby(by="fuel_draf")["efficiency_estimate"].mean().to_dict()
df["filler"] = df["fuel_draf"].map(filler_dic)

if fill_missing_efficiencies:
Expand Down

0 comments on commit 82b5677

Please sign in to comment.