Skip to content

Instantly share code, notes, and snippets.

@alonsosilvaallende
Created August 13, 2021 15:44
Show Gist options
  • Save alonsosilvaallende/3b611e660f2ee6b57ac1819e086ffa07 to your computer and use it in GitHub Desktop.
Save alonsosilvaallende/3b611e660f2ee6b57ac1819e086ffa07 to your computer and use it in GitHub Desktop.
Test1_prod89.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Test1_prod89.ipynb",
"provenance": [],
"collapsed_sections": [],
"authorship_tag": "ABX9TyPHIMyFHZKt9dBUhTLpDHK2",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/alonsosilvaallende/3b611e660f2ee6b57ac1819e086ffa07/test1_prod89.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "qxswDCTVHgzt"
},
"source": [
"import pandas as pd\n",
"import datetime"
],
"execution_count": 1,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "BaH8d6nMHi0u"
},
"source": [
"segunda_raw = pd.read_csv(\"https://raw.githubusercontent.com/MinCiencia/Datos-COVID19/master/output/producto78/vacunados_edad_fecha_2daDosis.csv\",\n",
" index_col=\"Edad\")\n",
"unica_raw = pd.read_csv(\"https://raw.githubusercontent.com/MinCiencia/Datos-COVID19/master/output/producto78/vacunados_edad_fecha_UnicaDosis.csv\",\n",
" index_col=\"Edad\")"
],
"execution_count": 2,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "-GP94cRJHmdX"
},
"source": [
"df_unica = pd.DataFrame()\n",
"df_unica['12-20'] = unica_raw.iloc[:9].sum().cumsum()\n",
"df_unica['21-30'] = unica_raw.iloc[9:19].sum().cumsum()\n",
"df_unica['31-40'] = unica_raw.iloc[19:29].sum().cumsum()\n",
"df_unica['41-50'] = unica_raw.iloc[29:39].sum().cumsum()\n",
"df_unica['51-60'] = unica_raw.iloc[39:49].sum().cumsum()\n",
"df_unica['61-70'] = unica_raw.iloc[49:59].sum().cumsum()\n",
"df_unica['71-80'] = unica_raw.iloc[59:69].sum().cumsum()\n",
"df_unica['>80'] = unica_raw.iloc[69:].sum().cumsum()\n",
"df_unica['Pob. >= 12'] = unica_raw.sum().cumsum()"
],
"execution_count": 3,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "wd0PpYmwH9xQ"
},
"source": [
"df_unica.index = pd.to_datetime(df_unica.index)+datetime.timedelta(28)"
],
"execution_count": 4,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "k2CYRrVyHxl8"
},
"source": [
"df_2da = pd.DataFrame()\n",
"df_2da['12-20'] = segunda_raw.iloc[:9].sum().cumsum()\n",
"df_2da['21-30'] = segunda_raw.iloc[9:19].sum().cumsum()\n",
"df_2da['31-40'] = segunda_raw.iloc[19:29].sum().cumsum()\n",
"df_2da['41-50'] = segunda_raw.iloc[29:39].sum().cumsum()\n",
"df_2da['51-60'] = segunda_raw.iloc[39:49].sum().cumsum()\n",
"df_2da['61-70'] = segunda_raw.iloc[49:59].sum().cumsum()\n",
"df_2da['71-80'] = segunda_raw.iloc[59:69].sum().cumsum()\n",
"df_2da['>80'] = segunda_raw.iloc[69:].sum().cumsum()\n",
"df_2da['Pob. >= 12'] = segunda_raw.sum().cumsum()"
],
"execution_count": 5,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "7cQE322dISQI"
},
"source": [
"df_2da.index = pd.to_datetime(df_2da.index)+datetime.timedelta(14)"
],
"execution_count": 6,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "Gaso-krkIzcJ"
},
"source": [
"df_final = df_2da.loc[\"2021-01-21\":\"2021-08-26\"]+df_unica.loc[\"2021-01-21\":\"2021-08-26\"]"
],
"execution_count": 7,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 363
},
"id": "1oid4ncAJBJM",
"outputId": "ba1c7c86-5552-46af-8a1a-f43e9586af29"
},
"source": [
"df_final = df_final.loc[\"2021-08-01\"].reset_index().rename(columns={'index':\"grupo_edad\"}).set_index(\"grupo_edad\")\n",
"df_final"
],
"execution_count": 8,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>2021-08-01 00:00:00</th>\n",
" </tr>\n",
" <tr>\n",
" <th>grupo_edad</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>12-20</th>\n",
" <td>388901.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21-30</th>\n",
" <td>2087010.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>31-40</th>\n",
" <td>2284656.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>41-50</th>\n",
" <td>2104696.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>51-60</th>\n",
" <td>2126039.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>61-70</th>\n",
" <td>1571056.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>71-80</th>\n",
" <td>898659.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>&gt;80</th>\n",
" <td>417947.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Pob. &gt;= 12</th>\n",
" <td>11878964.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 2021-08-01 00:00:00\n",
"grupo_edad \n",
"12-20 388901.0\n",
"21-30 2087010.0\n",
"31-40 2284656.0\n",
"41-50 2104696.0\n",
"51-60 2126039.0\n",
"61-70 1571056.0\n",
"71-80 898659.0\n",
">80 417947.0\n",
"Pob. >= 12 11878964.0"
]
},
"metadata": {
"tags": []
},
"execution_count": 8
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "G49CVzUHItHn"
},
"source": [
"df_prod89 = pd.read_csv(\"https://raw.githubusercontent.com/MinCiencia/Datos-COVID19/master/output/producto89/incidencia_en_vacunados_edad.csv\")"
],
"execution_count": 9,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 363
},
"id": "nWZzgmSQKT-m",
"outputId": "9ea261d3-1137-448b-a098-e55948276838"
},
"source": [
"df_prod89[df_prod89[\"estado_vacunacion\"]==\"con esquema completo\"][[\"grupo_edad\", \"poblacion\"]].set_index(\"grupo_edad\")"
],
"execution_count": 10,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>poblacion</th>\n",
" </tr>\n",
" <tr>\n",
" <th>grupo_edad</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>12 - 20 años</th>\n",
" <td>413860</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21 - 30 años</th>\n",
" <td>2007876</td>\n",
" </tr>\n",
" <tr>\n",
" <th>31 - 40 años</th>\n",
" <td>2247414</td>\n",
" </tr>\n",
" <tr>\n",
" <th>41 - 50 años</th>\n",
" <td>2085048</td>\n",
" </tr>\n",
" <tr>\n",
" <th>51 - 60 años</th>\n",
" <td>2115164</td>\n",
" </tr>\n",
" <tr>\n",
" <th>61 - 70 años</th>\n",
" <td>1576802</td>\n",
" </tr>\n",
" <tr>\n",
" <th>71 - 80 años</th>\n",
" <td>900838</td>\n",
" </tr>\n",
" <tr>\n",
" <th>80 años o más</th>\n",
" <td>418650</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Total</th>\n",
" <td>11765652</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" poblacion\n",
"grupo_edad \n",
"12 - 20 años 413860\n",
"21 - 30 años 2007876\n",
"31 - 40 años 2247414\n",
"41 - 50 años 2085048\n",
"51 - 60 años 2115164\n",
"61 - 70 años 1576802\n",
"71 - 80 años 900838\n",
"80 años o más 418650\n",
"Total 11765652"
]
},
"metadata": {
"tags": []
},
"execution_count": 10
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "jfQqciSuKV4k"
},
"source": [
""
],
"execution_count": 10,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment