{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "AVfznQKR-I--" }, "source": [ "# Visualizacion del Coronavirus (COVID19) Mundial con plotly\n", "por: Jose R. Zapata - https://joserzapata.github.io/\n", "\n", "\n", "Link: https://joserzapata.github.io/post/covid19-visualizacion/\n", "\n", "He visto en las redes sociales varias visualizaciones de los datos del COVID 19 y queria realizarlos en Python para tener la actualizacion de las graficas\n", "actualizadas cada dia, y ademas practicar el uso de [plotly](https://plotly.com/) para visualizacion interactiva.\n", "\n", "Las Graficas se actualizaran diariamente con los nuevos datos!\n", "\n", "Informacion extraida de 2019 Novel Coronavirus COVID-19 (2019-nCoV) Data Repository by Johns Hopkins CSSE\n", "\n", "https://github.com/CSSEGISandData/COVID-19\n", "\n", "**Actualizaciones**\n", "- 25/May/2020 agregar datos de personas recuperadas\n", "- 29/May/2020 actualizacion a plotly 0.48\n", "- 25/Sep/2020 Mapa Mundial de Confirmados por Pais con choropleth\n", "- 24/Nov/2022 Top 10 progresion paises\n", "- 21/Oct/2023 actualizar graficas y librerias" ] }, { "cell_type": "markdown", "metadata": { "id": "l8tbwHgTf71J" }, "source": [ "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/JoseRZapata/covid_plots/blob/main/notebooks/Covid19_Visualizacion_es.ipynb) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/JoseRZapata/covid_plots/HEAD?labpath=notebooks%2FCovid19_Visualizacion_es.ipynb) [![nbviewer](https://img.shields.io/badge/render-nbviewer-orange.svg)](https://nbviewer.jupyter.org/github/JoseRZapata/covid_plots/blob/main/notebooks/Covid19_Visualizacion_es.ipynb)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "id": "Fx_yb96YHeOb" }, "outputs": [], "source": [ "#!pip install chart_studio -q\n", "import chart_studio\n", "import numpy as np\n", "import pandas as pd\n", "import plotly.express as px" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "pandas version: 2.1.1\n", "numpy version: 1.26.0\n" ] } ], "source": [ "# print pandas, px an numpy version\n", "print(\"pandas version: \", pd.__version__)\n", "print(\"numpy version: \", np.__version__)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "id": "Ihyj4DOWzcdo", "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "api_key loaded!\n" ] } ], "source": [ "# Leer archivo con los datos de acceso a chart_studio\n", "# si no esta, dejar los campos vacios\n", "try:\n", " with open(\"../../info_chart.csv\") as f:\n", " info_user = f.read().split(\";\")\n", " username = info_user[0] # your username\n", " api_key = info_user[1] # your api key\n", " print(\"api_key loaded!\")\n", "except FileNotFoundError:\n", " username = \"\" # your username\n", " api_key = \"\"\n", "\n", "if api_key:\n", " chart_studio.tools.set_credentials_file(username=username, api_key=api_key)\n", "import chart_studio.plotly as py" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "id": "lT7Dgoqy-YQA" }, "outputs": [], "source": [ "# Leer datos\n", "\n", "# los datos de personas recuperadas no eran confiables entonces\n", "# ya solo se tienen los datos de confirmados y muertos\n", "\n", "confirmed = pd.read_csv(\n", " \"https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv\"\n", ")\n", "death = pd.read_csv(\n", " \"https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv\"\n", ")\n", "recovered = pd.read_csv(\n", " \"https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_recovered_global.csv\"\n", ")" ] }, { "cell_type": "markdown", "metadata": { "id": "1nocx9xeA5UY" }, "source": [ "## Datos CSSEGISandData/COVID-19\n", "\n", "Descripcion de los datos\n", "\n", "**Province/State:** China - province name; US/Canada/Australia/ - city name, state/province name; Others - name of the event (e.g., \"Diamond Princess\" cruise ship); other countries - blank.\n", "\n", "**Country/Region:** country/region name conforming to WHO (will be updated).\n", "\n", "**Last Update:** MM/DD/YYYY HH:mm (24 hour format, in UTC).\n", "\n", "**Confirmed: **the number of confirmed cases. For Hubei Province: from Feb 13 (GMT +8), we report both clinically diagnosed and lab-confirmed cases. For lab-confirmed cases only (Before Feb 17), please refer to who_covid_19_situation_reports. For Italy, diagnosis standard might be changed since Feb 27 to \"slow the growth of new case numbers.\"\n", "\n", "**Deaths:** the number of deaths.\n", "\n", "**Recovered:** the number of recovered cases." ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "id": "fTZI2C13_rsQ" }, "outputs": [ { "data": { "text/html": [ "
\n", " | Province/State | \n", "Country/Region | \n", "Lat | \n", "Long | \n", "1/22/20 | \n", "1/23/20 | \n", "1/24/20 | \n", "1/25/20 | \n", "
---|---|---|---|---|---|---|---|---|
0 | \n", "NaN | \n", "Afghanistan | \n", "33.93911 | \n", "67.709953 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
1 | \n", "NaN | \n", "Albania | \n", "41.15330 | \n", "20.168300 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
2 | \n", "NaN | \n", "Algeria | \n", "28.03390 | \n", "1.659600 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
3 | \n", "NaN | \n", "Andorra | \n", "42.50630 | \n", "1.521800 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
4 | \n", "NaN | \n", "Angola | \n", "-11.20270 | \n", "17.873900 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "