From 53421b1346a5977b2f774fead6e309a3a971e4c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Mon, 18 Dec 2023 20:21:45 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=94=20Add=20marker=5Fsize=20column?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ddj_cloud/scrapers/talsperren/exporters/map.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ddj_cloud/scrapers/talsperren/exporters/map.py b/ddj_cloud/scrapers/talsperren/exporters/map.py index 12b2e39..e46c3de 100644 --- a/ddj_cloud/scrapers/talsperren/exporters/map.py +++ b/ddj_cloud/scrapers/talsperren/exporters/map.py @@ -161,6 +161,16 @@ def _add_monthly_fill_percent_to_map( return df_map + def _add_marker_size(self, df_map: pd.DataFrame) -> pd.DataFrame: + source_column = df_map["capacity_mio_m3"] + df_map.insert( + 1, + "marker_size", + (source_column - source_column.min()) / (source_column.max() - source_column.min()) * 95 + + 5, + ) + return df_map + def run(self, df_base: pd.DataFrame) -> pd.DataFrame: df_base.insert(0, "id", df_base["federation_name"] + "_" + df_base["name"]) @@ -180,6 +190,9 @@ def run(self, df_base: pd.DataFrame) -> pd.DataFrame: # Add monthly fill ratio df_map = self._add_monthly_fill_percent_to_map(df_base, df_map) + # Add marker size + df_map = self._add_marker_size(df_map) + # round all floats to 5 decimals df_map = df_map.round(5)