From 3b77b4a370c869d927bf9710c0aeee34a48d7663 Mon Sep 17 00:00:00 2001 From: Johannes Schmidt Date: Mon, 6 May 2024 18:46:04 +0200 Subject: [PATCH] Fix that code works if either ES or PT is present --- scripts/build_hydro_profile.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/build_hydro_profile.py b/scripts/build_hydro_profile.py index f1e56532..ed3bbd1d 100644 --- a/scripts/build_hydro_profile.py +++ b/scripts/build_hydro_profile.py @@ -139,8 +139,10 @@ def approximate_missing_eia_stats(eia_stats, runoff_fn, countries): runoff.index = runoff.index.astype(int) # fix outliers; exceptional floods in 1977-1979 in ES & PT - if ("ES" and "PT") in runoff: - runoff.loc[1978, ["ES", "PT"]] = runoff.loc[1979, ["ES", "PT"]] + if "ES" in runoff: + runoff.loc[1978, ["ES"]] = runoff.loc[1979, ["ES"]] + if "PT" in runoff: + runoff.loc[1978, ["PT"]] = runoff.loc[1979, ["PT"]] runoff_eia = runoff.loc[eia_stats.index]