From a8454fd8305dff8b5360536903f3d581125b062d Mon Sep 17 00:00:00 2001 From: Koen van Greevenbroek Date: Mon, 18 Mar 2024 16:16:30 +0000 Subject: [PATCH] Fill in missing eurostat data on domestic aviation energy demand --- scripts/build_energy_totals.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/build_energy_totals.py b/scripts/build_energy_totals.py index abab06e4..b56d3294 100644 --- a/scripts/build_energy_totals.py +++ b/scripts/build_energy_totals.py @@ -124,6 +124,17 @@ def build_eurostat(input_eurostat, countries, nprocesses=1, disable_progressbar= ) df = pd.concat([temp, df.loc[~int_avia]]) + # Fill in missing data on "Domestic aviation" for each country. + domestic_avia = df.index.get_level_values(4) == "Domestic aviation" + for country in countries: + slicer = idx[country, :, :, :, "Domestic aviation"] + # For the Total and Fossil energy columns, fill in zeros with + # the closest non-zero value in the year index. + for col in ["Total", "Fossil energy"]: + df.loc[slicer, col] = ( + df.loc[slicer, col].replace(0.0, np.nan).ffill().bfill() + ) + # Renaming some indices index_rename = { "Households": "Residential",