[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2024-07-22 19:42:52 +00:00
parent b957f88645
commit fb26aaf38d

View File

@ -609,7 +609,7 @@ def fill_missing_years(fill_values: pd.Series) -> pd.Series:
- The function groups the data by the 'country' level and computes the mean for each group. - The function groups the data by the 'country' level and computes the mean for each group.
- Zero values in the original Series are replaced by the mean value of their respective country group. - Zero values in the original Series are replaced by the mean value of their respective country group.
""" """
means = fill_values.groupby(level='country').transform('mean') means = fill_values.groupby(level="country").transform("mean")
return fill_values.where(fill_values != 0, means) return fill_values.where(fill_values != 0, means)
@ -686,7 +686,7 @@ def build_energy_totals(
y = to_fill.get_level_values("year") y = to_fill.get_level_values("year")
# take total final energy consumption from Eurostat # take total final energy consumption from Eurostat
eurostat_sector = 'Agriculture & forestry' eurostat_sector = "Agriculture & forestry"
slicer = idx[c, y, :, :, eurostat_sector] slicer = idx[c, y, :, :, eurostat_sector]
fill_values = eurostat.loc[slicer]["Total all products"].groupby(level=[0, 1]).sum() fill_values = eurostat.loc[slicer]["Total all products"].groupby(level=[0, 1]).sum()
@ -698,9 +698,12 @@ def build_energy_totals(
uses = ["electricity", "heat", "machinery"] uses = ["electricity", "heat", "machinery"]
for use in uses: for use in uses:
avg = (idees["total agriculture electricity"] avg = (
/idees["total agriculture"]).mean() idees["total agriculture electricity"] / idees["total agriculture"]
df.loc[to_fill, f"total agriculture {use}"] = df.loc[to_fill, "total agriculture"] * avg ).mean()
df.loc[to_fill, f"total agriculture {use}"] = (
df.loc[to_fill, "total agriculture"] * avg
)
# divide cooking/space/water according to averages in EU28 # divide cooking/space/water according to averages in EU28