From 7e75aab29537226dc348b27c31e26dac23ab23ed Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Wed, 7 Aug 2024 10:47:22 +0200 Subject: [PATCH] directly read in nan values --- scripts/build_energy_totals.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/build_energy_totals.py b/scripts/build_energy_totals.py index 0a407438..e508bd54 100644 --- a/scripts/build_energy_totals.py +++ b/scripts/build_energy_totals.py @@ -170,6 +170,7 @@ def eurostat_per_country(input_eurostat: str, country: str) -> pd.DataFrame: sheet_name=None, skiprows=4, index_col=list(range(4)), + na_values=":" ) sheet.pop("Cover") return pd.concat(sheet) @@ -502,7 +503,7 @@ def idees_per_country(ct: str, base_dir: str) -> pd.DataFrame: assert df.index[11] == "International - Extra-EEAwUK" - ct_totals["total international aviation freight"] = df.iloc[11].sum() + ct_totals["total international aviation freight"] = df.iloc[11] ct_totals["total domestic aviation"] = ( ct_totals["total domestic aviation freight"] @@ -607,8 +608,6 @@ def fill_missing_years(fill_values: pd.Series) -> pd.Series: - Zero values in the original Series are replaced by the ffilled and bfilled value of their respective country group. """ - # Replace zero values with NaN for correct filling - fill_values = fill_values.replace(0, pd.NA) # Forward fill and then backward fill within each country group fill_values = fill_values.groupby(level="country").ffill().bfill()