From da393f5a61108efa5d627352bc825c6fb8c5c75d Mon Sep 17 00:00:00 2001 From: yerbol-akhmetov Date: Mon, 4 Nov 2024 18:54:09 +0500 Subject: [PATCH 1/5] drop list entries in country column of CO2_emissions data in prepare_transport_data_input --- scripts/prepare_transport_data_input.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/prepare_transport_data_input.py b/scripts/prepare_transport_data_input.py index cffa163e2..93f570d70 100644 --- a/scripts/prepare_transport_data_input.py +++ b/scripts/prepare_transport_data_input.py @@ -103,6 +103,13 @@ def download_CO2_emissions(): # Drop region names that have no ISO2: CO2_emissions = CO2_emissions[CO2_emissions.country != "not found"] + # Drop region names where country column contains list of countries + CO2_emissions = CO2_emissions[ + CO2_emissions.apply( + lambda x: False if not isinstance(x.country, str) else True, axis=1 + ) + ] + return CO2_emissions From 7db113a1454e53d975a2ab7ad7854c0fe641c461 Mon Sep 17 00:00:00 2001 From: yerbol-akhmetov Date: Mon, 4 Nov 2024 18:57:44 +0500 Subject: [PATCH 2/5] add release notes --- doc/release_notes.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/release_notes.rst b/doc/release_notes.rst index 0d1b7c746..8f93f3825 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -42,6 +42,8 @@ E.g. if a new rule becomes available describe how to use it `make test` and in o * Fix bugs in `prepare_sector_network.py` related to links with H2 buses and bug of re-addition of H2 and battery carriers in present `PR #1145 `_ +* Drop entries that contain non-string elements in country column of `CO2_emissions_csv` data in `prepare_transport_data_input.py` script `PR #1166 `_ + PyPSA-Earth 0.4.1 ================= From f293e2cbfd8d689c51a52743f20af43f18572939 Mon Sep 17 00:00:00 2001 From: yerbol-akhmetov Date: Fri, 8 Nov 2024 23:15:48 +0500 Subject: [PATCH 3/5] remove redefining Series --- scripts/prepare_transport_data_input.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/prepare_transport_data_input.py b/scripts/prepare_transport_data_input.py index 93f570d70..0546dc84d 100644 --- a/scripts/prepare_transport_data_input.py +++ b/scripts/prepare_transport_data_input.py @@ -95,9 +95,8 @@ def download_CO2_emissions(): # Add ISO2 country code for each country CO2_emissions = CO2_emissions.rename(columns={"Country Name": "Country"}) cc = coco.CountryConverter() - Country = pd.Series(CO2_emissions["Country"]) - CO2_emissions["country"] = cc.pandas_convert( - series=Country, to="ISO2", not_found="not found" + CO2_emissions.loc[:, "country"] = cc.pandas_convert( + series=CO2_emissions["Country"], to="ISO2", not_found="not found" ) # Drop region names that have no ISO2: From f0bb82d1dcb59a95de2c2a9cb559ae2c45297bb0 Mon Sep 17 00:00:00 2001 From: Yerbol Akhmetov <113768325+yerbol-akhmetov@users.noreply.github.com> Date: Tue, 12 Nov 2024 15:34:54 +0500 Subject: [PATCH 4/5] Update scripts/prepare_transport_data_input.py Co-authored-by: Davide Fioriti <67809479+davide-f@users.noreply.github.com> --- scripts/prepare_transport_data_input.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/prepare_transport_data_input.py b/scripts/prepare_transport_data_input.py index 0546dc84d..b5c27fbe9 100644 --- a/scripts/prepare_transport_data_input.py +++ b/scripts/prepare_transport_data_input.py @@ -104,11 +104,8 @@ def download_CO2_emissions(): # Drop region names where country column contains list of countries CO2_emissions = CO2_emissions[ - CO2_emissions.apply( - lambda x: False if not isinstance(x.country, str) else True, axis=1 - ) + CO2_emissions.country.apply(lambda x: isinstance(x, str), axis=1) ] - return CO2_emissions From 7a7ffd40a2707a27487905bec4d88645ee016080 Mon Sep 17 00:00:00 2001 From: yerbol-akhmetov Date: Tue, 12 Nov 2024 15:42:09 +0500 Subject: [PATCH 5/5] no axis specification for series --- scripts/prepare_transport_data_input.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/prepare_transport_data_input.py b/scripts/prepare_transport_data_input.py index b5c27fbe9..dde4a3042 100644 --- a/scripts/prepare_transport_data_input.py +++ b/scripts/prepare_transport_data_input.py @@ -104,7 +104,7 @@ def download_CO2_emissions(): # Drop region names where country column contains list of countries CO2_emissions = CO2_emissions[ - CO2_emissions.country.apply(lambda x: isinstance(x, str), axis=1) + CO2_emissions.country.apply(lambda x: isinstance(x, str)) ] return CO2_emissions