diff --git a/example/china_export.ipynb b/example/china_export.ipynb new file mode 100644 index 0000000..92994db --- /dev/null +++ b/example/china_export.ipynb @@ -0,0 +1,4388 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "71a3cb34-4428-4c3a-bb19-d1c832c4a403", + "metadata": { + "id": "71a3cb34-4428-4c3a-bb19-d1c832c4a403" + }, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import plotly.express as px" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "4d0007f0-c4d1-4fea-b7cc-881afcde1c00", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "4d0007f0-c4d1-4fea-b7cc-881afcde1c00", + "outputId": "5beec45f-28b9-4f79-84e1-54609d650745" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "\n", + "RangeIndex: 209 entries, 0 to 208\n", + "Data columns (total 12 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 Unnamed: 0 0 non-null float64\n", + " 1 Unnamed: 1 209 non-null object \n", + " 2 2014 197 non-null float64\n", + " 3 2015 197 non-null float64\n", + " 4 2016 202 non-null float64\n", + " 5 2017 204 non-null float64\n", + " 6 2018 204 non-null float64\n", + " 7 2019 204 non-null float64\n", + " 8 2020 205 non-null float64\n", + " 9 2021 204 non-null float64\n", + " 10 2022 204 non-null float64\n", + " 11 2023 208 non-null float64\n", + "dtypes: float64(11), object(1)\n", + "memory usage: 19.7+ KB\n" + ] + } + ], + "source": [ + "df = pd.read_excel(\"https://github.com/wcj365/python-stats-dataviz/raw/refs/heads/master/example/Exports_to_Counterpart_Countries.xlsx\", skiprows=6)\n", + "df.info()" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "d62fdede-b283-4170-8f8a-6b953ef4c093", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 425 + }, + "id": "d62fdede-b283-4170-8f8a-6b953ef4c093", + "outputId": "2833ebea-8bf6-40b6-97ad-8a30376ef105" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + " 0\n", + "Unnamed: 0 NaN\n", + "Unnamed: 1 Afghanistan, Islamic Rep. of\n", + "2014 393.595177\n", + "2015 364.314188\n", + "2016 435.333\n", + "2017 541.155039\n", + "2018 670.73551\n", + "2019 600.99751\n", + "2020 500.82981\n", + "2021 474.550453\n", + "2022 553.84399\n", + "2023 1268.57214" + ], + "text/html": [ + "\n", + "
\n", + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
0
Unnamed: 0NaN
Unnamed: 1Afghanistan, Islamic Rep. of
2014393.595177
2015364.314188
2016435.333
2017541.155039
2018670.73551
2019600.99751
2020500.82981
2021474.550453
2022553.84399
20231268.57214
\n", + "
\n", + "
\n", + "\n", + "
\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "
\n", + "\n", + "\n", + "
\n", + " \n", + "\n", + "\n", + "\n", + " \n", + "
\n", + "\n", + "
\n", + "
\n" + ], + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "dataframe", + "variable_name": "df", + "summary": "{\n \"name\": \"df\",\n \"rows\": 209,\n \"fields\": [\n {\n \"column\": \"Unnamed: 0\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": null,\n \"min\": null,\n \"max\": null,\n \"num_unique_values\": 0,\n \"samples\": [],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Unnamed: 1\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 209,\n \"samples\": [],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2014\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 41619.21545346958,\n \"min\": 0.778176,\n \"max\": 397099.314578,\n \"num_unique_values\": 197,\n \"samples\": [],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2015\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 40712.73193707389,\n \"min\": 2.613572,\n \"max\": 410782.81502,\n \"num_unique_values\": 197,\n \"samples\": [],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2016\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 37367.865498626,\n \"min\": 0.11,\n \"max\": 389714.449,\n \"num_unique_values\": 202,\n \"samples\": [],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2017\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 39586.68404642735,\n \"min\": 0.083997,\n \"max\": 433744.887853,\n \"num_unique_values\": 204,\n \"samples\": [],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2018\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 43460.41310161052,\n \"min\": 0.00653,\n \"max\": 480688.674,\n \"num_unique_values\": 204,\n \"samples\": [],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2019\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 39702.19498494612,\n \"min\": 0.00603,\n \"max\": 418584.24966,\n \"num_unique_values\": 204,\n \"samples\": [],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2020\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 41688.83188656883,\n \"min\": 0.40269,\n \"max\": 452832.22287,\n \"num_unique_values\": 205,\n \"samples\": [],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2021\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 53261.410734861754,\n \"min\": 0.214511,\n \"max\": 577636.302833,\n \"num_unique_values\": 204,\n \"samples\": [],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2022\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 53394.319754524186,\n \"min\": 0.07537,\n \"max\": 582539.06388,\n \"num_unique_values\": 204,\n \"samples\": [],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2023\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 47710.44330856778,\n \"min\": 0.112657,\n \"max\": 506980.581369,\n \"num_unique_values\": 208,\n \"samples\": [],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}" + } + }, + "metadata": {}, + "execution_count": 9 + } + ], + "source": [ + "df.head(1).T" + ] + }, + { + "cell_type": "code", + "source": [ + "df.drop(columns=[\"Unnamed: 0\"], inplace=True)\n", + "df.head()" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 206 + }, + "id": "v_xfNPpk2um7", + "outputId": "bdfd8f66-15a3-4fee-b354-87ce3b8325e7" + }, + "id": "v_xfNPpk2um7", + "execution_count": 10, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + " Unnamed: 1 2014 2015 2016 \\\n", + "0 Afghanistan, Islamic Rep. of 393.595177 364.314188 435.333 \n", + "1 Albania 379.081082 430.255025 517.879 \n", + "2 Algeria 7389.710403 7600.059993 7801.954 \n", + "3 American Samoa NaN NaN NaN \n", + "4 Angola 5976.272076 3722.322952 1761.205 \n", + "\n", + " 2017 2018 2019 2020 2021 2022 \\\n", + "0 541.155039 670.73551 600.99751 500.82981 474.550453 553.84399 \n", + "1 454.226281 543.36360 598.52415 571.23461 591.912755 703.18992 \n", + "2 6790.115108 7939.87951 6945.57126 5598.98900 6352.718906 6284.87790 \n", + "3 NaN NaN NaN NaN NaN NaN \n", + "4 2297.792937 2245.34040 2057.49484 1750.83735 2494.912435 4125.19302 \n", + "\n", + " 2023 \n", + "0 1268.572140 \n", + "1 1107.703729 \n", + "2 9548.942594 \n", + "3 24.450960 \n", + "4 4368.929997 " + ], + "text/html": [ + "\n", + "
\n", + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Unnamed: 12014201520162017201820192020202120222023
0Afghanistan, Islamic Rep. of393.595177364.314188435.333541.155039670.73551600.99751500.82981474.550453553.843991268.572140
1Albania379.081082430.255025517.879454.226281543.36360598.52415571.23461591.912755703.189921107.703729
2Algeria7389.7104037600.0599937801.9546790.1151087939.879516945.571265598.989006352.7189066284.877909548.942594
3American SamoaNaNNaNNaNNaNNaNNaNNaNNaNNaN24.450960
4Angola5976.2720763722.3229521761.2052297.7929372245.340402057.494841750.837352494.9124354125.193024368.929997
\n", + "
\n", + "
\n", + "\n", + "
\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "
\n", + "\n", + "\n", + "
\n", + " \n", + "\n", + "\n", + "\n", + " \n", + "
\n", + "\n", + "
\n", + "
\n" + ], + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "dataframe", + "variable_name": "df", + "summary": "{\n \"name\": \"df\",\n \"rows\": 209,\n \"fields\": [\n {\n \"column\": \"Unnamed: 1\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 209,\n \"samples\": [\n \"Burundi\",\n \"South Africa\",\n \"Holy See\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2014\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 41619.21545346958,\n \"min\": 0.778176,\n \"max\": 397099.314578,\n \"num_unique_values\": 197,\n \"samples\": [\n 23460.639536,\n 756.57761,\n 17222.472654\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2015\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 40712.73193707389,\n \"min\": 2.613572,\n \"max\": 410782.81502,\n \"num_unique_values\": 197,\n \"samples\": [\n 26687.713887,\n 803.874232,\n 16220.763717\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2016\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 37367.865498626,\n \"min\": 0.11,\n \"max\": 389714.449,\n \"num_unique_values\": 202,\n \"samples\": [\n 26.502,\n 1100.181,\n 4010.626\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2017\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 39586.68404642735,\n \"min\": 0.083997,\n \"max\": 433744.887853,\n \"num_unique_values\": 204,\n \"samples\": [\n 934.46623,\n 2527.140217,\n 3084.572835\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2018\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 43460.41310161052,\n \"min\": 0.00653,\n \"max\": 480688.674,\n \"num_unique_values\": 204,\n \"samples\": [\n 1145.42166,\n 2844.64609,\n 2165.76727\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2019\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 39702.19498494612,\n \"min\": 0.00603,\n \"max\": 418584.24966,\n \"num_unique_values\": 204,\n \"samples\": [\n 1777.67595,\n 3021.83215,\n 2384.71531\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2020\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 41688.83188656883,\n \"min\": 0.40269,\n \"max\": 452832.22287,\n \"num_unique_values\": 205,\n \"samples\": [\n 2109.3890499999993,\n 3399.01529,\n 2876.41346\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2021\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 53261.410734861754,\n \"min\": 0.214511,\n \"max\": 577636.302833,\n \"num_unique_values\": 204,\n \"samples\": [\n 2732.371422,\n 5349.794375,\n 3178.47771\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2022\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 53394.319754524186,\n \"min\": 0.07537,\n \"max\": 582539.06388,\n \"num_unique_values\": 204,\n \"samples\": [\n 3277.55076,\n 5097.92784,\n 3463.52615\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2023\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 47710.44330856778,\n \"min\": 0.112657,\n \"max\": 506980.581369,\n \"num_unique_values\": 208,\n \"samples\": [\n 2702.611861,\n 23219.663559,\n 9558.202105\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}" + } + }, + "metadata": {}, + "execution_count": 10 + } + ] + }, + { + "cell_type": "code", + "source": [ + "df.rename(columns={\"Unnamed: 1\" : \"Country\"}, inplace=True)\n", + "df.head()" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 206 + }, + "id": "6osqS16x28nO", + "outputId": "cb9e654f-2a34-4626-a07d-a55a1f6f2e46" + }, + "id": "6osqS16x28nO", + "execution_count": 12, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + " Country 2014 2015 2016 \\\n", + "0 Afghanistan, Islamic Rep. of 393.595177 364.314188 435.333 \n", + "1 Albania 379.081082 430.255025 517.879 \n", + "2 Algeria 7389.710403 7600.059993 7801.954 \n", + "3 American Samoa NaN NaN NaN \n", + "4 Angola 5976.272076 3722.322952 1761.205 \n", + "\n", + " 2017 2018 2019 2020 2021 2022 \\\n", + "0 541.155039 670.73551 600.99751 500.82981 474.550453 553.84399 \n", + "1 454.226281 543.36360 598.52415 571.23461 591.912755 703.18992 \n", + "2 6790.115108 7939.87951 6945.57126 5598.98900 6352.718906 6284.87790 \n", + "3 NaN NaN NaN NaN NaN NaN \n", + "4 2297.792937 2245.34040 2057.49484 1750.83735 2494.912435 4125.19302 \n", + "\n", + " 2023 \n", + "0 1268.572140 \n", + "1 1107.703729 \n", + "2 9548.942594 \n", + "3 24.450960 \n", + "4 4368.929997 " + ], + "text/html": [ + "\n", + "
\n", + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Country2014201520162017201820192020202120222023
0Afghanistan, Islamic Rep. of393.595177364.314188435.333541.155039670.73551600.99751500.82981474.550453553.843991268.572140
1Albania379.081082430.255025517.879454.226281543.36360598.52415571.23461591.912755703.189921107.703729
2Algeria7389.7104037600.0599937801.9546790.1151087939.879516945.571265598.989006352.7189066284.877909548.942594
3American SamoaNaNNaNNaNNaNNaNNaNNaNNaNNaN24.450960
4Angola5976.2720763722.3229521761.2052297.7929372245.340402057.494841750.837352494.9124354125.193024368.929997
\n", + "
\n", + "
\n", + "\n", + "
\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "
\n", + "\n", + "\n", + "
\n", + " \n", + "\n", + "\n", + "\n", + " \n", + "
\n", + "\n", + "
\n", + "
\n" + ], + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "dataframe", + "variable_name": "df", + "summary": "{\n \"name\": \"df\",\n \"rows\": 209,\n \"fields\": [\n {\n \"column\": \"Country\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 209,\n \"samples\": [\n \"Burundi\",\n \"South Africa\",\n \"Holy See\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2014\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 41619.21545346958,\n \"min\": 0.778176,\n \"max\": 397099.314578,\n \"num_unique_values\": 197,\n \"samples\": [\n 23460.639536,\n 756.57761,\n 17222.472654\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2015\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 40712.73193707389,\n \"min\": 2.613572,\n \"max\": 410782.81502,\n \"num_unique_values\": 197,\n \"samples\": [\n 26687.713887,\n 803.874232,\n 16220.763717\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2016\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 37367.865498626,\n \"min\": 0.11,\n \"max\": 389714.449,\n \"num_unique_values\": 202,\n \"samples\": [\n 26.502,\n 1100.181,\n 4010.626\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2017\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 39586.68404642735,\n \"min\": 0.083997,\n \"max\": 433744.887853,\n \"num_unique_values\": 204,\n \"samples\": [\n 934.46623,\n 2527.140217,\n 3084.572835\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2018\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 43460.41310161052,\n \"min\": 0.00653,\n \"max\": 480688.674,\n \"num_unique_values\": 204,\n \"samples\": [\n 1145.42166,\n 2844.64609,\n 2165.76727\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2019\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 39702.19498494612,\n \"min\": 0.00603,\n \"max\": 418584.24966,\n \"num_unique_values\": 204,\n \"samples\": [\n 1777.67595,\n 3021.83215,\n 2384.71531\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2020\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 41688.83188656883,\n \"min\": 0.40269,\n \"max\": 452832.22287,\n \"num_unique_values\": 205,\n \"samples\": [\n 2109.3890499999993,\n 3399.01529,\n 2876.41346\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2021\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 53261.410734861754,\n \"min\": 0.214511,\n \"max\": 577636.302833,\n \"num_unique_values\": 204,\n \"samples\": [\n 2732.371422,\n 5349.794375,\n 3178.47771\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2022\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 53394.319754524186,\n \"min\": 0.07537,\n \"max\": 582539.06388,\n \"num_unique_values\": 204,\n \"samples\": [\n 3277.55076,\n 5097.92784,\n 3463.52615\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2023\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 47710.44330856778,\n \"min\": 0.112657,\n \"max\": 506980.581369,\n \"num_unique_values\": 208,\n \"samples\": [\n 2702.611861,\n 23219.663559,\n 9558.202105\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}" + } + }, + "metadata": {}, + "execution_count": 12 + } + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "75d7e01d-a7bc-4a92-9c09-55a18ba70bf5", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "75d7e01d-a7bc-4a92-9c09-55a18ba70bf5", + "outputId": "b4418e27-f014-41ef-b21e-e85361229678" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "['Afghanistan, Islamic Rep. of', 'Albania', 'Algeria', 'American Samoa', 'Angola', 'Anguilla', 'Antigua and Barbuda', 'Argentina', 'Armenia, Rep. of', 'Aruba, Kingdom of the Netherlands', 'Australia', 'Austria', 'Azerbaijan, Rep. of', 'Bahamas, The', 'Bahrain, Kingdom of', 'Bangladesh', 'Barbados', 'Belarus, Rep. of', 'Belgium', 'Belize', 'Benin', 'Bermuda', 'Bhutan', 'Bolivia', 'Bosnia and Herzegovina', 'Botswana', 'Brazil', 'Brunei Darussalam', 'Bulgaria', 'Burkina Faso', 'Burundi', 'Cabo Verde', 'Cambodia', 'Cameroon', 'Canada', 'Central African Rep.', 'Chad', 'Chile', 'China, P.R.: Hong Kong', 'China, P.R.: Macao', 'Colombia', 'Comoros, Union of the', 'Congo, Dem. Rep. of the', 'Congo, Rep. of', 'Costa Rica', \"Côte d'Ivoire\", 'Croatia, Rep. of', 'Cuba', 'Curaçao, Kingdom of the Netherlands', 'Cyprus', 'Czech Rep.', 'Denmark', 'Djibouti', 'Dominica', 'Dominican Rep.', 'Ecuador', 'Egypt, Arab Rep. of', 'El Salvador', 'Equatorial Guinea, Rep. of', 'Eritrea, The State of', 'Estonia, Rep. of', 'Eswatini, Kingdom of', 'Ethiopia, The Federal Dem. Rep. of', 'Falkland Islands (Malvinas)', 'Faroe Islands', 'Fiji, Rep. of', 'Finland', 'France', 'French Polynesia', 'Gabon', 'Gambia, The', 'Georgia', 'Germany', 'Ghana', 'Gibraltar', 'Greece', 'Greenland', 'Grenada', 'Guam', 'Guatemala', 'Guinea', 'Guinea-Bissau', 'Guyana', 'Haiti', 'Holy See', 'Honduras', 'Hungary', 'Iceland', 'India', 'Indonesia', 'Iran, Islamic Rep. of', 'Iraq', 'Ireland', 'Israel', 'Italy', 'Jamaica', 'Japan', 'Jordan', 'Kazakhstan, Rep. of', 'Kenya', 'Kiribati', \"Korea, Dem. People's Rep. of\", 'Korea, Rep. of', 'Kuwait', 'Kyrgyz Rep.', \"Lao People's Dem. Rep.\", 'Latvia', 'Lebanon', 'Lesotho, Kingdom of', 'Liberia', 'Libya', 'Lithuania', 'Luxembourg', 'Madagascar, Rep. of', 'Malawi', 'Malaysia', 'Maldives', 'Mali', 'Malta', 'Marshall Islands, Rep. of the', 'Mauritania, Islamic Rep. of', 'Mauritius', 'Mexico', 'Micronesia, Federated States of', 'Moldova, Rep. of', 'Mongolia', 'Montenegro', 'Montserrat', 'Morocco', 'Mozambique, Rep. of', 'Myanmar', 'Namibia', 'Nauru, Rep. of', 'Nepal', 'Netherlands Antilles', 'Netherlands, The', 'New Caledonia', 'New Zealand', 'Nicaragua', 'Niger', 'Nigeria', 'North Macedonia, Republic of', 'Norway', 'Oman', 'Pakistan', 'Palau, Rep. of', 'Panama', 'Papua New Guinea', 'Paraguay', 'Peru', 'Philippines', 'Poland, Rep. of', 'Portugal', 'Qatar', 'Romania', 'Russian Federation', 'Rwanda', 'Samoa', 'San Marino, Rep. of', 'São Tomé and Príncipe, Dem. Rep. of', 'Saudi Arabia', 'Senegal', 'Serbia, Rep. of', 'Seychelles', 'Sierra Leone', 'Singapore', 'Sint Maarten, Kingdom of the Netherlands', 'Slovak Rep.', 'Slovenia, Rep. of', 'Solomon Islands', 'Somalia', 'South Africa', 'South Sudan, Rep. of', 'Spain', 'Sri Lanka', 'St. Kitts and Nevis', 'St. Lucia', 'St. Vincent and the Grenadines', 'Sudan', 'Suriname', 'Sweden', 'Switzerland', 'Syrian Arab Rep.', 'Taiwan Province of China', 'Tajikistan, Rep. of', 'Tanzania, United Rep. of', 'Thailand', 'Timor-Leste, Dem. Rep. of', 'Togo', 'Tonga', 'Trinidad and Tobago', 'Tunisia', 'Türkiye, Rep of', 'Turkmenistan', 'Tuvalu', 'Uganda', 'Ukraine', 'United Arab Emirates', 'United Kingdom', 'United States', 'Uruguay', 'Uzbekistan, Rep. of', 'Vanuatu', 'Venezuela, Rep. Bolivariana de', 'Vietnam', 'West Bank and Gaza', 'Yemen, Rep. of', 'Zambia', 'Zimbabwe']\n" + ] + } + ], + "source": [ + "print(list(df[\"Country\"]))" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "ea5831ba-a9fe-417f-8cfd-cfe83c458046", + "metadata": { + "id": "ea5831ba-a9fe-417f-8cfd-cfe83c458046" + }, + "outputs": [], + "source": [ + "G7 = [\n", + " \"Japan\",\n", + " \"United States\",\n", + " \"Canada\",\n", + " \"United Kingdom\",\n", + " \"Germany\",\n", + " \"France\",\n", + " \"Italy\"\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "681e02a2-f8d8-4986-97fe-1200ca1ede99", + "metadata": { + "id": "681e02a2-f8d8-4986-97fe-1200ca1ede99" + }, + "outputs": [], + "source": [ + "BRICS = [\n", + " \"Brazil\",\n", + " \"Russian Federation\",\n", + " \"India\",\n", + " \"China\",\n", + " \"South Africa\"\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "fa3b0ec4-6536-4ef6-a144-ecd2b1c926f8", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 175 + }, + "id": "fa3b0ec4-6536-4ef6-a144-ecd2b1c926f8", + "outputId": "66a734d7-576e-47a2-f6b4-679df81b772e" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + " Country 2014 2015 2016 2017 \\\n", + "26 Brazil 34925.220202 27428.465829 22175.708 29256.991988 \n", + "88 India 54237.234329 58259.172477 59435.206 68143.365122 \n", + "155 Russian Federation 53685.678792 34810.190576 37696.489 43321.242882 \n", + "171 South Africa 15705.299259 15879.966658 13027.306 14970.562392 \n", + "\n", + " 2018 2019 2020 2021 2022 \\\n", + "26 33793.14333 35476.98259 34972.51421 53632.251368 61881.24574 \n", + "88 77023.15837 74924.28533 66779.53849 97588.360882 118769.03469 \n", + "155 48073.66052 49484.54046 50608.37060 67595.805013 76264.80448 \n", + "171 16405.86722 16560.93309 15259.95047 21131.739533 24223.77175 \n", + "\n", + " 2023 \n", + "26 59349.620232 \n", + "88 118631.691733 \n", + "155 111442.040177 \n", + "171 23827.735375 " + ], + "text/html": [ + "\n", + "
\n", + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Country2014201520162017201820192020202120222023
26Brazil34925.22020227428.46582922175.70829256.99198833793.1433335476.9825934972.5142153632.25136861881.2457459349.620232
88India54237.23432958259.17247759435.20668143.36512277023.1583774924.2853366779.5384997588.360882118769.03469118631.691733
155Russian Federation53685.67879234810.19057637696.48943321.24288248073.6605249484.5404650608.3706067595.80501376264.80448111442.040177
171South Africa15705.29925915879.96665813027.30614970.56239216405.8672216560.9330915259.9504721131.73953324223.7717523827.735375
\n", + "
\n", + "
\n", + "\n", + "
\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "
\n", + "\n", + "\n", + "
\n", + " \n", + "\n", + "\n", + "\n", + " \n", + "
\n", + "\n", + "
\n", + " \n", + " \n", + " \n", + "
\n", + "\n", + "
\n", + "
\n" + ], + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "dataframe", + "variable_name": "df_brics", + "summary": "{\n \"name\": \"df_brics\",\n \"rows\": 4,\n \"fields\": [\n {\n \"column\": \"Country\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 4,\n \"samples\": [\n \"India\",\n \"South Africa\",\n \"Brazil\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2014\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 18307.18784253774,\n \"min\": 15705.299259,\n \"max\": 54237.234329,\n \"num_unique_values\": 4,\n \"samples\": [\n 54237.234329,\n 15705.299259,\n 34925.220202\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2015\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 17894.588058465935,\n \"min\": 15879.966658,\n \"max\": 58259.172477,\n \"num_unique_values\": 4,\n \"samples\": [\n 58259.172477,\n 15879.966658,\n 27428.465829\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2016\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 20305.359888297036,\n \"min\": 13027.306,\n \"max\": 59435.206,\n \"num_unique_values\": 4,\n \"samples\": [\n 59435.206,\n 13027.306,\n 22175.708\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2017\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 22659.253125074876,\n \"min\": 14970.562392,\n \"max\": 68143.365122,\n \"num_unique_values\": 4,\n \"samples\": [\n 68143.365122,\n 14970.562392,\n 29256.991988\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2018\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 25642.515618142912,\n \"min\": 16405.86722,\n \"max\": 77023.15837,\n \"num_unique_values\": 4,\n \"samples\": [\n 77023.15837,\n 16405.86722,\n 33793.14333\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2019\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 24575.637878503418,\n \"min\": 16560.93309,\n \"max\": 74924.28533,\n \"num_unique_values\": 4,\n \"samples\": [\n 74924.28533,\n 16560.93309,\n 35476.98259\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2020\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 22003.85836272975,\n \"min\": 15259.95047,\n \"max\": 66779.53849,\n \"num_unique_values\": 4,\n \"samples\": [\n 66779.53849,\n 15259.95047,\n 34972.51421\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2021\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 31737.83415227755,\n \"min\": 21131.739533,\n \"max\": 97588.360882,\n \"num_unique_values\": 4,\n \"samples\": [\n 97588.360882,\n 21131.739533,\n 53632.251368\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2022\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 39067.11965610984,\n \"min\": 24223.77175,\n \"max\": 118769.03469,\n \"num_unique_values\": 4,\n \"samples\": [\n 118769.03469,\n 24223.77175,\n 61881.24574\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2023\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 44912.44830921406,\n \"min\": 23827.735375,\n \"max\": 118631.691733,\n \"num_unique_values\": 4,\n \"samples\": [\n 118631.691733,\n 23827.735375,\n 59349.620232\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}" + } + }, + "metadata": {}, + "execution_count": 16 + } + ], + "source": [ + "df_brics = df[df[\"Country\"].isin(BRICS)]\n", + "df_brics" + ] + }, + { + "cell_type": "code", + "source": [ + "df_g7 = df[df[\"Country\"].isin(G7)]\n", + "df_g7" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 269 + }, + "id": "Tf8qdNGw3fAE", + "outputId": "7f50febf-f8ce-4cff-a296-83faf60f1ca1" + }, + "id": "Tf8qdNGw3fAE", + "execution_count": 17, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + " Country 2014 2015 2016 2017 \\\n", + "34 Canada 30000.360501 29407.031846 27854.748 31765.289661 \n", + "67 France 28975.685738 27048.097462 25303.217 28123.923487 \n", + "72 Germany 72730.919502 69203.670501 66044.117 71463.824369 \n", + "94 Italy 28759.021215 27849.191986 26565.225 29282.194225 \n", + "96 Japan 149451.720062 135897.054589 129617.467 137528.612225 \n", + "198 United Kingdom 57132.740473 59663.882424 56645.733 57407.305759 \n", + "199 United States 397099.314578 410782.815020 389714.449 433744.887853 \n", + "\n", + " 2018 2019 2020 2021 2022 \\\n", + "34 35660.22317 36827.41750 42126.45771 51568.165676 53745.07565 \n", + "67 31247.81043 33104.05587 37272.08862 46474.440428 46070.90056 \n", + "72 78154.62412 79706.09116 86997.60612 115267.202321 116212.01278 \n", + "94 33325.40139 33410.76053 32946.53773 43647.651843 50875.15664 \n", + "96 147564.60806 143223.96913 142721.94845 165902.055079 173096.27477 \n", + "198 57291.28504 62275.95891 72666.49194 87126.462937 81594.43600 \n", + "199 480688.67400 418584.24966 452832.22287 577636.302833 582539.06388 \n", + "\n", + " 2023 \n", + "34 45526.733250 \n", + "67 42273.029382 \n", + "72 101097.172137 \n", + "94 44660.652184 \n", + "96 158089.831394 \n", + "198 78917.606033 \n", + "199 506980.581369 " + ], + "text/html": [ + "\n", + "
\n", + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Country2014201520162017201820192020202120222023
34Canada30000.36050129407.03184627854.74831765.28966135660.2231736827.4175042126.4577151568.16567653745.0756545526.733250
67France28975.68573827048.09746225303.21728123.92348731247.8104333104.0558737272.0886246474.44042846070.9005642273.029382
72Germany72730.91950269203.67050166044.11771463.82436978154.6241279706.0911686997.60612115267.202321116212.01278101097.172137
94Italy28759.02121527849.19198626565.22529282.19422533325.4013933410.7605332946.5377343647.65184350875.1566444660.652184
96Japan149451.720062135897.054589129617.467137528.612225147564.60806143223.96913142721.94845165902.055079173096.27477158089.831394
198United Kingdom57132.74047359663.88242456645.73357407.30575957291.2850462275.9589172666.4919487126.46293781594.4360078917.606033
199United States397099.314578410782.815020389714.449433744.887853480688.67400418584.24966452832.22287577636.302833582539.06388506980.581369
\n", + "
\n", + "
\n", + "\n", + "
\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "
\n", + "\n", + "\n", + "
\n", + " \n", + "\n", + "\n", + "\n", + " \n", + "
\n", + "\n", + "
\n", + " \n", + " \n", + " \n", + "
\n", + "\n", + "
\n", + "
\n" + ], + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "dataframe", + "variable_name": "df_g7", + "summary": "{\n \"name\": \"df_g7\",\n \"rows\": 7,\n \"fields\": [\n {\n \"column\": \"Country\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 7,\n \"samples\": [\n \"Canada\",\n \"France\",\n \"United Kingdom\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2014\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 133994.07652787448,\n \"min\": 28759.021215,\n \"max\": 397099.314578,\n \"num_unique_values\": 7,\n \"samples\": [\n 30000.360501,\n 28975.685738,\n 57132.740473\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2015\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 138713.92140272152,\n \"min\": 27048.097462,\n \"max\": 410782.81502,\n \"num_unique_values\": 7,\n \"samples\": [\n 29407.031846,\n 27048.097462,\n 59663.882424\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2016\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 131626.94424544417,\n \"min\": 25303.217,\n \"max\": 389714.449,\n \"num_unique_values\": 7,\n \"samples\": [\n 27854.748,\n 25303.217,\n 56645.733\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2017\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 146689.03041707995,\n \"min\": 28123.923487,\n \"max\": 433744.887853,\n \"num_unique_values\": 7,\n \"samples\": [\n 31765.289661,\n 28123.923487,\n 57407.305759\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2018\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 162767.91062031485,\n \"min\": 31247.81043,\n \"max\": 480688.674,\n \"num_unique_values\": 7,\n \"samples\": [\n 35660.22317,\n 31247.81043,\n 57291.28504\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2019\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 139319.49268349863,\n \"min\": 33104.05587,\n \"max\": 418584.24966,\n \"num_unique_values\": 7,\n \"samples\": [\n 36827.4175,\n 33104.05587,\n 62275.95891\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2020\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 150000.6453583986,\n \"min\": 32946.53773,\n \"max\": 452832.22287,\n \"num_unique_values\": 7,\n \"samples\": [\n 42126.45771,\n 37272.08862,\n 72666.49194\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2021\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 191398.4134631923,\n \"min\": 43647.651843,\n \"max\": 577636.302833,\n \"num_unique_values\": 7,\n \"samples\": [\n 51568.165676,\n 46474.440428,\n 87126.462937\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2022\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 192751.05143577297,\n \"min\": 46070.90056,\n \"max\": 582539.06388,\n \"num_unique_values\": 7,\n \"samples\": [\n 53745.07565,\n 46070.90056,\n 81594.436\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2023\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 167237.83839694926,\n \"min\": 42273.029382,\n \"max\": 506980.581369,\n \"num_unique_values\": 7,\n \"samples\": [\n 45526.73325,\n 42273.029382,\n 78917.606033\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}" + } + }, + "metadata": {}, + "execution_count": 17 + } + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "4126e7bf-55b4-41b9-9e55-2eb738c0eb65", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 206 + }, + "id": "4126e7bf-55b4-41b9-9e55-2eb738c0eb65", + "outputId": "1e2baaa3-3f32-40bb-caba-9f4deddd5a8d" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + " Country 2014 2015 2016 \\\n", + "75 Greece 4185.522679 3665.170172 4296.247 \n", + "176 St. Lucia 29.902284 21.279800 17.122 \n", + "138 Nicaragua 568.175325 668.711502 629.847 \n", + "101 Korea, Dem. People's Rep. of 3522.515381 2946.463633 3196.804 \n", + "48 Curaçao, Kingdom of the Netherlands NaN NaN 5.637 \n", + "\n", + " 2017 2018 2019 2020 2021 \\\n", + "75 4817.393627 6572.27081 7740.22412 7041.06083 11197.259898 \n", + "176 15.981584 18.95977 21.51917 23.28916 25.419035 \n", + "138 625.911267 475.58244 501.83614 486.68959 795.157659 \n", + "101 3328.068320 2238.87694 2588.88649 491.25346 261.312065 \n", + "48 30.008509 41.10146 41.80709 35.52325 40.067232 \n", + "\n", + " 2022 2023 Group \n", + "75 13020.62140 12996.826564 REST OF WORLD \n", + "176 36.00210 45.450811 REST OF WORLD \n", + "138 724.69064 830.298353 REST OF WORLD \n", + "101 895.33667 2030.303224 REST OF WORLD \n", + "48 61.04651 58.344765 REST OF WORLD " + ], + "text/html": [ + "\n", + "
\n", + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Country2014201520162017201820192020202120222023Group
75Greece4185.5226793665.1701724296.2474817.3936276572.270817740.224127041.0608311197.25989813020.6214012996.826564REST OF WORLD
176St. Lucia29.90228421.27980017.12215.98158418.9597721.5191723.2891625.41903536.0021045.450811REST OF WORLD
138Nicaragua568.175325668.711502629.847625.911267475.58244501.83614486.68959795.157659724.69064830.298353REST OF WORLD
101Korea, Dem. People's Rep. of3522.5153812946.4636333196.8043328.0683202238.876942588.88649491.25346261.312065895.336672030.303224REST OF WORLD
48Curaçao, Kingdom of the NetherlandsNaNNaN5.63730.00850941.1014641.8070935.5232540.06723261.0465158.344765REST OF WORLD
\n", + "
\n", + "
\n", + "\n", + "
\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "
\n", + "\n", + "\n", + "
\n", + " \n", + "\n", + "\n", + "\n", + " \n", + "
\n", + "\n", + "
\n", + "
\n" + ], + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "dataframe", + "summary": "{\n \"name\": \"df\",\n \"rows\": 5,\n \"fields\": [\n {\n \"column\": \"Country\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"St. Lucia\",\n \"Cura\\u00e7ao, Kingdom of the Netherlands\",\n \"Nicaragua\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2014\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 2081.8695664898855,\n \"min\": 29.902284,\n \"max\": 4185.522679,\n \"num_unique_values\": 4,\n \"samples\": [\n 29.902284,\n 3522.515381,\n 4185.522679\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2015\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1754.452994745277,\n \"min\": 21.2798,\n \"max\": 3665.170172,\n \"num_unique_values\": 4,\n \"samples\": [\n 21.2798,\n 2946.463633,\n 3665.170172\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2016\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1987.7110384281966,\n \"min\": 5.637,\n \"max\": 4296.247,\n \"num_unique_values\": 5,\n \"samples\": [\n 17.122,\n 5.637,\n 629.847\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2017\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 2186.7248225553517,\n \"min\": 15.981584,\n \"max\": 4817.393627,\n \"num_unique_values\": 5,\n \"samples\": [\n 15.981584,\n 30.008509,\n 625.911267\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2018\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 2782.222090468949,\n \"min\": 18.95977,\n \"max\": 6572.27081,\n \"num_unique_values\": 5,\n \"samples\": [\n 18.95977,\n 41.10146,\n 475.58244\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2019\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 3283.687569696349,\n \"min\": 21.51917,\n \"max\": 7740.22412,\n \"num_unique_values\": 5,\n \"samples\": [\n 21.51917,\n 41.80709,\n 501.83614\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2020\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 3041.6408159907223,\n \"min\": 23.28916,\n \"max\": 7041.06083,\n \"num_unique_values\": 5,\n \"samples\": [\n 23.28916,\n 35.52325,\n 486.68959\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2021\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 4892.055406672188,\n \"min\": 25.419035,\n \"max\": 11197.259898,\n \"num_unique_values\": 5,\n \"samples\": [\n 25.419035,\n 40.067232,\n 795.157659\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2022\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 5644.210845789002,\n \"min\": 36.0021,\n \"max\": 13020.6214,\n \"num_unique_values\": 5,\n \"samples\": [\n 36.0021,\n 61.04651,\n 724.69064\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2023\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 5540.360201513846,\n \"min\": 45.450811,\n \"max\": 12996.826564,\n \"num_unique_values\": 5,\n \"samples\": [\n 45.450811,\n 58.344765,\n 830.298353\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Group\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 1,\n \"samples\": [\n \"REST OF WORLD\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}" + } + }, + "metadata": {}, + "execution_count": 18 + } + ], + "source": [ + "def assign_group(country):\n", + " if country in BRICS:\n", + " return \"BRICS\"\n", + " elif country in G7:\n", + " return \"G7\"\n", + " else:\n", + " return \"REST OF WORLD\"\n", + "\n", + "\n", + "df[\"Group\"] = df[\"Country\"].apply(assign_group)\n", + "\n", + "df.sample(5)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "e7e2ef80-327d-4fb1-a721-25151b69fee9", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 209 + }, + "id": "e7e2ef80-327d-4fb1-a721-25151b69fee9", + "outputId": "a18132ea-bd9e-48a6-e65e-99a3d107e556" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "Group\n", + "REST OF WORLD 198\n", + "G7 7\n", + "BRICS 4\n", + "Name: count, dtype: int64" + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
count
Group
REST OF WORLD198
G77
BRICS4
\n", + "

" + ] + }, + "metadata": {}, + "execution_count": 19 + } + ], + "source": [ + "df[\"Group\"].value_counts()" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "6f841f85-1429-4047-a5f5-f5a6e7f01a0d", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 143 + }, + "id": "6f841f85-1429-4047-a5f5-f5a6e7f01a0d", + "outputId": "77af38ac-2eca-4727-e0bd-ade1b94c155f" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + " Group 2014 2015 2016 2017 \\\n", + "0 BRICS 1.585534e+05 1.363778e+05 132334.709 1.556922e+05 \n", + "1 G7 7.641498e+05 7.598517e+05 721744.956 7.893160e+05 \n", + "2 REST OF WORLD 1.418350e+06 1.379748e+06 1278043.845 1.334666e+06 \n", + "\n", + " 2018 2019 2020 2021 2022 \\\n", + "0 1.752958e+05 1.764467e+05 1.676204e+05 2.399482e+05 2.811389e+05 \n", + "1 8.639326e+05 8.071325e+05 8.675634e+05 1.087622e+06 1.104133e+06 \n", + "2 1.461899e+06 1.514782e+06 1.562662e+06 2.040418e+06 2.218810e+06 \n", + "\n", + " 2023 \n", + "0 3.132511e+05 \n", + "1 9.775456e+05 \n", + "2 2.131004e+06 " + ], + "text/html": [ + "\n", + "
\n", + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Group2014201520162017201820192020202120222023
0BRICS1.585534e+051.363778e+05132334.7091.556922e+051.752958e+051.764467e+051.676204e+052.399482e+052.811389e+053.132511e+05
1G77.641498e+057.598517e+05721744.9567.893160e+058.639326e+058.071325e+058.675634e+051.087622e+061.104133e+069.775456e+05
2REST OF WORLD1.418350e+061.379748e+061278043.8451.334666e+061.461899e+061.514782e+061.562662e+062.040418e+062.218810e+062.131004e+06
\n", + "
\n", + "
\n", + "\n", + "
\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "
\n", + "\n", + "\n", + "
\n", + " \n", + "\n", + "\n", + "\n", + " \n", + "
\n", + "\n", + "
\n", + " \n", + " \n", + " \n", + "
\n", + "\n", + "
\n", + "
\n" + ], + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "dataframe", + "variable_name": "df_group", + "summary": "{\n \"name\": \"df_group\",\n \"rows\": 3,\n \"fields\": [\n {\n \"column\": \"Group\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 3,\n \"samples\": [\n \"BRICS\",\n \"G7\",\n \"REST OF WORLD\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2014\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 630054.4800608049,\n \"min\": 158553.43258199998,\n \"max\": 1418349.903394,\n \"num_unique_values\": 3,\n \"samples\": [\n 158553.43258199998,\n 764149.7620689999,\n 1418349.903394\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2015\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 621685.7870717,\n \"min\": 136377.79554,\n \"max\": 1379747.653601,\n \"num_unique_values\": 3,\n \"samples\": [\n 136377.79554,\n 759851.743828,\n 1379747.653601\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2016\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 572934.3065141502,\n \"min\": 132334.709,\n \"max\": 1278043.845,\n \"num_unique_values\": 3,\n \"samples\": [\n 132334.709,\n 721744.956,\n 1278043.845\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2017\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 590037.2194710111,\n \"min\": 155692.162384,\n \"max\": 1334665.5405889999,\n \"num_unique_values\": 3,\n \"samples\": [\n 155692.162384,\n 789316.037579,\n 1334665.5405889999\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2018\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 643833.6810540098,\n \"min\": 175295.82944,\n \"max\": 1461898.65844,\n \"num_unique_values\": 3,\n \"samples\": [\n 175295.82944,\n 863932.6262099999,\n 1461898.65844\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2019\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 669536.2623879333,\n \"min\": 176446.74147,\n \"max\": 1514781.81311,\n \"num_unique_values\": 3,\n \"samples\": [\n 176446.74147,\n 807132.5027600001,\n 1514781.81311\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2020\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 697521.9669152199,\n \"min\": 167620.37377,\n \"max\": 1562661.50334,\n \"num_unique_values\": 3,\n \"samples\": [\n 167620.37377,\n 867563.35344,\n 1562661.50334\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2021\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 900746.1310610145,\n \"min\": 239948.156796,\n \"max\": 2040417.781437,\n \"num_unique_values\": 3,\n \"samples\": [\n 239948.156796,\n 1087622.281117,\n 2040417.781437\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2022\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 972487.9266284339,\n \"min\": 281138.85666,\n \"max\": 2218810.47899,\n \"num_unique_values\": 3,\n \"samples\": [\n 281138.85666,\n 1104132.92028,\n 2218810.47899\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"2023\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 919780.4748686634,\n \"min\": 313251.087517,\n \"max\": 2131003.597241,\n \"num_unique_values\": 3,\n \"samples\": [\n 313251.087517,\n 977545.6057490001,\n 2131003.597241\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}" + } + }, + "metadata": {}, + "execution_count": 20 + } + ], + "source": [ + "df_group = df.select_dtypes(include='number').groupby(df[\"Group\"]).sum().reset_index()\n", + "df_group" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "2aa72594-eaca-43cf-9840-a6330b53887f", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 990 + }, + "id": "2aa72594-eaca-43cf-9840-a6330b53887f", + "outputId": "c3ec8edd-f1b1-4108-8636-553921b03023" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + " Group Year Export\n", + "0 BRICS 2014 1.585534e+05\n", + "1 G7 2014 7.641498e+05\n", + "2 REST OF WORLD 2014 1.418350e+06\n", + "3 BRICS 2015 1.363778e+05\n", + "4 G7 2015 7.598517e+05\n", + "5 REST OF WORLD 2015 1.379748e+06\n", + "6 BRICS 2016 1.323347e+05\n", + "7 G7 2016 7.217450e+05\n", + "8 REST OF WORLD 2016 1.278044e+06\n", + "9 BRICS 2017 1.556922e+05\n", + "10 G7 2017 7.893160e+05\n", + "11 REST OF WORLD 2017 1.334666e+06\n", + "12 BRICS 2018 1.752958e+05\n", + "13 G7 2018 8.639326e+05\n", + "14 REST OF WORLD 2018 1.461899e+06\n", + "15 BRICS 2019 1.764467e+05\n", + "16 G7 2019 8.071325e+05\n", + "17 REST OF WORLD 2019 1.514782e+06\n", + "18 BRICS 2020 1.676204e+05\n", + "19 G7 2020 8.675634e+05\n", + "20 REST OF WORLD 2020 1.562662e+06\n", + "21 BRICS 2021 2.399482e+05\n", + "22 G7 2021 1.087622e+06\n", + "23 REST OF WORLD 2021 2.040418e+06\n", + "24 BRICS 2022 2.811389e+05\n", + "25 G7 2022 1.104133e+06\n", + "26 REST OF WORLD 2022 2.218810e+06\n", + "27 BRICS 2023 3.132511e+05\n", + "28 G7 2023 9.775456e+05\n", + "29 REST OF WORLD 2023 2.131004e+06" + ], + "text/html": [ + "\n", + "
\n", + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
GroupYearExport
0BRICS20141.585534e+05
1G720147.641498e+05
2REST OF WORLD20141.418350e+06
3BRICS20151.363778e+05
4G720157.598517e+05
5REST OF WORLD20151.379748e+06
6BRICS20161.323347e+05
7G720167.217450e+05
8REST OF WORLD20161.278044e+06
9BRICS20171.556922e+05
10G720177.893160e+05
11REST OF WORLD20171.334666e+06
12BRICS20181.752958e+05
13G720188.639326e+05
14REST OF WORLD20181.461899e+06
15BRICS20191.764467e+05
16G720198.071325e+05
17REST OF WORLD20191.514782e+06
18BRICS20201.676204e+05
19G720208.675634e+05
20REST OF WORLD20201.562662e+06
21BRICS20212.399482e+05
22G720211.087622e+06
23REST OF WORLD20212.040418e+06
24BRICS20222.811389e+05
25G720221.104133e+06
26REST OF WORLD20222.218810e+06
27BRICS20233.132511e+05
28G720239.775456e+05
29REST OF WORLD20232.131004e+06
\n", + "
\n", + "
\n", + "\n", + "
\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "
\n", + "\n", + "\n", + "
\n", + " \n", + "\n", + "\n", + "\n", + " \n", + "
\n", + "\n", + "
\n", + " \n", + " \n", + " \n", + "
\n", + "\n", + "
\n", + "
\n" + ], + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "dataframe", + "variable_name": "df_melt", + "summary": "{\n \"name\": \"df_melt\",\n \"rows\": 30,\n \"fields\": [\n {\n \"column\": \"Group\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 3,\n \"samples\": [\n \"BRICS\",\n \"G7\",\n \"REST OF WORLD\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Year\",\n \"properties\": {\n \"dtype\": \"object\",\n \"num_unique_values\": 10,\n \"samples\": [\n \"2022\",\n \"2015\",\n \"2019\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Export\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 635687.5712810985,\n \"min\": 132334.709,\n \"max\": 2218810.47899,\n \"num_unique_values\": 30,\n \"samples\": [\n 313251.087517,\n 176446.74147,\n 2040417.781437\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}" + } + }, + "metadata": {}, + "execution_count": 21 + } + ], + "source": [ + "df_melt =pd.melt(df_group, id_vars=[\"Group\"], var_name='Year', value_name='Export')\n", + "df_melt" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "5e1dee2e-6d1a-46a2-a3e5-96c5a0891237", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 542 + }, + "id": "5e1dee2e-6d1a-46a2-a3e5-96c5a0891237", + "outputId": "6609333c-ecaf-4457-97d1-842c8163f91e" + }, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/html": [ + "\n", + "\n", + "\n", + "
\n", + "
\n", + "\n", + "" + ] + }, + "metadata": {} + } + ], + "source": [ + "fig = px.bar(df_melt, x=\"Year\", y=\"Export\", color=\"Group\", barmode=\"group\")\n", + "fig.show()" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "a8a0dac6-01f5-4def-b81f-0f86bf30bd92", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000 + }, + "id": "a8a0dac6-01f5-4def-b81f-0f86bf30bd92", + "outputId": "fba14de9-d567-43dc-d173-117a35cdaafc" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "0 2.341053e+06\n", + "1 2.341053e+06\n", + "2 2.341053e+06\n", + "3 2.275977e+06\n", + "4 2.275977e+06\n", + "5 2.275977e+06\n", + "6 2.132124e+06\n", + "7 2.132124e+06\n", + "8 2.132124e+06\n", + "9 2.279674e+06\n", + "10 2.279674e+06\n", + "11 2.279674e+06\n", + "12 2.501127e+06\n", + "13 2.501127e+06\n", + "14 2.501127e+06\n", + "15 2.498361e+06\n", + "16 2.498361e+06\n", + "17 2.498361e+06\n", + "18 2.597845e+06\n", + "19 2.597845e+06\n", + "20 2.597845e+06\n", + "21 3.367988e+06\n", + "22 3.367988e+06\n", + "23 3.367988e+06\n", + "24 3.604082e+06\n", + "25 3.604082e+06\n", + "26 3.604082e+06\n", + "27 3.421800e+06\n", + "28 3.421800e+06\n", + "29 3.421800e+06\n", + "Name: Export, dtype: float64" + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Export
02.341053e+06
12.341053e+06
22.341053e+06
32.275977e+06
42.275977e+06
52.275977e+06
62.132124e+06
72.132124e+06
82.132124e+06
92.279674e+06
102.279674e+06
112.279674e+06
122.501127e+06
132.501127e+06
142.501127e+06
152.498361e+06
162.498361e+06
172.498361e+06
182.597845e+06
192.597845e+06
202.597845e+06
213.367988e+06
223.367988e+06
233.367988e+06
243.604082e+06
253.604082e+06
263.604082e+06
273.421800e+06
283.421800e+06
293.421800e+06
\n", + "

" + ] + }, + "metadata": {}, + "execution_count": 24 + } + ], + "source": [ + "# Compute the total value per category\n", + "\n", + "df_total = df_melt.groupby(\"Year\")['Export'].transform('sum')\n", + "\n", + "df_total" + ] + }, + { + "cell_type": "code", + "source": [ + "# Compute the percentage of the total value within each group\n", + "df_melt['Percentage'] = round((df_melt['Export'] / df_total) * 100, 1)\n", + "\n", + "df_melt\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 990 + }, + "id": "oSicsLUj6Q2f", + "outputId": "a8331ac6-2a4a-4167-8cba-8fa87205d16b" + }, + "id": "oSicsLUj6Q2f", + "execution_count": 26, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + " Group Year Export Percentage\n", + "0 BRICS 2014 1.585534e+05 6.8\n", + "1 G7 2014 7.641498e+05 32.6\n", + "2 REST OF WORLD 2014 1.418350e+06 60.6\n", + "3 BRICS 2015 1.363778e+05 6.0\n", + "4 G7 2015 7.598517e+05 33.4\n", + "5 REST OF WORLD 2015 1.379748e+06 60.6\n", + "6 BRICS 2016 1.323347e+05 6.2\n", + "7 G7 2016 7.217450e+05 33.9\n", + "8 REST OF WORLD 2016 1.278044e+06 59.9\n", + "9 BRICS 2017 1.556922e+05 6.8\n", + "10 G7 2017 7.893160e+05 34.6\n", + "11 REST OF WORLD 2017 1.334666e+06 58.5\n", + "12 BRICS 2018 1.752958e+05 7.0\n", + "13 G7 2018 8.639326e+05 34.5\n", + "14 REST OF WORLD 2018 1.461899e+06 58.4\n", + "15 BRICS 2019 1.764467e+05 7.1\n", + "16 G7 2019 8.071325e+05 32.3\n", + "17 REST OF WORLD 2019 1.514782e+06 60.6\n", + "18 BRICS 2020 1.676204e+05 6.5\n", + "19 G7 2020 8.675634e+05 33.4\n", + "20 REST OF WORLD 2020 1.562662e+06 60.2\n", + "21 BRICS 2021 2.399482e+05 7.1\n", + "22 G7 2021 1.087622e+06 32.3\n", + "23 REST OF WORLD 2021 2.040418e+06 60.6\n", + "24 BRICS 2022 2.811389e+05 7.8\n", + "25 G7 2022 1.104133e+06 30.6\n", + "26 REST OF WORLD 2022 2.218810e+06 61.6\n", + "27 BRICS 2023 3.132511e+05 9.2\n", + "28 G7 2023 9.775456e+05 28.6\n", + "29 REST OF WORLD 2023 2.131004e+06 62.3" + ], + "text/html": [ + "\n", + "
\n", + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
GroupYearExportPercentage
0BRICS20141.585534e+056.8
1G720147.641498e+0532.6
2REST OF WORLD20141.418350e+0660.6
3BRICS20151.363778e+056.0
4G720157.598517e+0533.4
5REST OF WORLD20151.379748e+0660.6
6BRICS20161.323347e+056.2
7G720167.217450e+0533.9
8REST OF WORLD20161.278044e+0659.9
9BRICS20171.556922e+056.8
10G720177.893160e+0534.6
11REST OF WORLD20171.334666e+0658.5
12BRICS20181.752958e+057.0
13G720188.639326e+0534.5
14REST OF WORLD20181.461899e+0658.4
15BRICS20191.764467e+057.1
16G720198.071325e+0532.3
17REST OF WORLD20191.514782e+0660.6
18BRICS20201.676204e+056.5
19G720208.675634e+0533.4
20REST OF WORLD20201.562662e+0660.2
21BRICS20212.399482e+057.1
22G720211.087622e+0632.3
23REST OF WORLD20212.040418e+0660.6
24BRICS20222.811389e+057.8
25G720221.104133e+0630.6
26REST OF WORLD20222.218810e+0661.6
27BRICS20233.132511e+059.2
28G720239.775456e+0528.6
29REST OF WORLD20232.131004e+0662.3
\n", + "
\n", + "
\n", + "\n", + "
\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "
\n", + "\n", + "\n", + "
\n", + " \n", + "\n", + "\n", + "\n", + " \n", + "
\n", + "\n", + "
\n", + " \n", + " \n", + " \n", + "
\n", + "\n", + "
\n", + "
\n" + ], + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "dataframe", + "variable_name": "df_melt", + "summary": "{\n \"name\": \"df_melt\",\n \"rows\": 30,\n \"fields\": [\n {\n \"column\": \"Group\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 3,\n \"samples\": [\n \"BRICS\",\n \"G7\",\n \"REST OF WORLD\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Year\",\n \"properties\": {\n \"dtype\": \"object\",\n \"num_unique_values\": 10,\n \"samples\": [\n \"2022\",\n \"2015\",\n \"2019\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Export\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 635687.5712810985,\n \"min\": 132334.709,\n \"max\": 2218810.47899,\n \"num_unique_values\": 30,\n \"samples\": [\n 313251.087517,\n 176446.74147,\n 2040417.781437\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Percentage\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 22.16916674173814,\n \"min\": 6.0,\n \"max\": 62.3,\n \"num_unique_values\": 23,\n \"samples\": [\n 6.5,\n 58.5,\n 6.8\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}" + } + }, + "metadata": {}, + "execution_count": 26 + } + ] + }, + { + "cell_type": "code", + "source": [ + "fig = px.bar(df_melt, x=\"Year\", y=\"Percentage\", color=\"Group\", barmode=\"stack\")\n", + "fig.show()" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 542 + }, + "id": "cT5dcqmY6j7G", + "outputId": "b8cbfbe5-e92b-4c45-aea0-0bd91d064744" + }, + "id": "cT5dcqmY6j7G", + "execution_count": 27, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/html": [ + "\n", + "\n", + "\n", + "
\n", + "
\n", + "\n", + "" + ] + }, + "metadata": {} + } + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "packages-kernel", + "language": "python", + "name": "packages-venv" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.3" + }, + "colab": { + "provenance": [], + "include_colab_link": true + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} \ No newline at end of file