From 132b14bc0c9291d3b5f0513f05bcfb4bd1c8ee58 Mon Sep 17 00:00:00 2001 From: "Iker S. Requerey" Date: Thu, 28 Nov 2024 13:04:59 +0000 Subject: [PATCH] replace nan with null --- .../notebooks/04_prepare_tabular_data.ipynb | 59 ++++++++++--------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/data-processing/notebooks/04_prepare_tabular_data.ipynb b/data-processing/notebooks/04_prepare_tabular_data.ipynb index 0559f32..ee07e96 100644 --- a/data-processing/notebooks/04_prepare_tabular_data.ipynb +++ b/data-processing/notebooks/04_prepare_tabular_data.ipynb @@ -80,7 +80,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -117,7 +117,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -151,29 +151,29 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "{'Agricultural drought exposure': ,\n", - " 'Agricultural drought hazard': ,\n", - " 'Boundaries': ,\n", - " 'Contextual layers': ,\n", - " 'EO-based flood exposure': ,\n", - " 'EO-based flood hazard': ,\n", - " 'Hydrographic data': ,\n", - " 'Hydrometeorological Data': ,\n", - " 'In-situ Data': ,\n", - " 'Meteorological drought exposure': ,\n", - " 'Meteorological drought hazard': ,\n", - " 'Model-based flood exposure': ,\n", - " 'Model-based flood hazard': ,\n", - " 'Populated infrastructures': ,\n", - " 'Transportation Network Infrastructures': ,\n", - " 'Water-related infrastructures': }\n" + "{'Agricultural drought exposure': ,\n", + " 'Agricultural drought hazard': ,\n", + " 'Boundaries': ,\n", + " 'Contextual layers': ,\n", + " 'EO-based flood exposure': ,\n", + " 'EO-based flood hazard': ,\n", + " 'Hydrographic data': ,\n", + " 'Hydrometeorological Data': ,\n", + " 'In-situ Data': ,\n", + " 'Meteorological drought exposure': ,\n", + " 'Meteorological drought hazard': ,\n", + " 'Model-based flood exposure': ,\n", + " 'Model-based flood hazard': ,\n", + " 'Populated infrastructures': ,\n", + " 'Transportation Network Infrastructures': ,\n", + " 'Water-related infrastructures': }\n" ] } ], @@ -191,20 +191,20 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'Administrative Boundaries - adm0': ,\n", - " 'Administrative Boundaries - adm1': ,\n", - " 'Administrative Boundaries - adm2': ,\n", - " 'Administrative Boundaries - adm3': ,\n", - " 'Hydrological Basins': }" + "{'Administrative Boundaries - adm0': ,\n", + " 'Administrative Boundaries - adm1': ,\n", + " 'Administrative Boundaries - adm2': ,\n", + " 'Administrative Boundaries - adm3': ,\n", + " 'Hydrological Basins': }" ] }, - "execution_count": 4, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -335,7 +335,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -352,7 +352,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -408,13 +408,14 @@ "\n", " for _index, row in df.iterrows():\n", " code = str(row[code_column])\n", + " y_values = convert_string_to_float_list(row[\"y_axis_values\"])\n", "\n", " chart_data = {\n", " \"id\": chart_id,\n", " \"location_code\": str(row[code_column]),\n", " \"year\": int(row[\"year\"]),\n", " \"x_values\": literal_eval(row[\"x_axis_values\"]),\n", - " \"y_values\": convert_string_to_float_list(row[\"y_axis_values\"]),\n", + " \"y_values\": [None if math.isnan(value) else value for value in y_values],\n", " \"createdAt\": datetime.now().isoformat(),\n", " \"updatedAt\": datetime.now().isoformat(),\n", " \"layer\": layer_id,\n",