|
|
- {
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 150,
- "metadata": {},
- "outputs": [
- {
- "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>DateRep</th>\n",
- " <th>Day</th>\n",
- " <th>Month</th>\n",
- " <th>Year</th>\n",
- " <th>Cases</th>\n",
- " <th>Deaths</th>\n",
- " <th>Countries and territories</th>\n",
- " <th>GeoId</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>0</th>\n",
- " <td>24/03/2020</td>\n",
- " <td>24</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>6</td>\n",
- " <td>1</td>\n",
- " <td>Afghanistan</td>\n",
- " <td>AF</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>1</th>\n",
- " <td>23/03/2020</td>\n",
- " <td>23</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>10</td>\n",
- " <td>0</td>\n",
- " <td>Afghanistan</td>\n",
- " <td>AF</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>2</th>\n",
- " <td>22/03/2020</td>\n",
- " <td>22</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Afghanistan</td>\n",
- " <td>AF</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3</th>\n",
- " <td>21/03/2020</td>\n",
- " <td>21</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>2</td>\n",
- " <td>0</td>\n",
- " <td>Afghanistan</td>\n",
- " <td>AF</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>4</th>\n",
- " <td>20/03/2020</td>\n",
- " <td>20</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Afghanistan</td>\n",
- " <td>AF</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>...</th>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>6546</th>\n",
- " <td>19/03/2020</td>\n",
- " <td>19</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>2</td>\n",
- " <td>0</td>\n",
- " <td>Zambia</td>\n",
- " <td>ZM</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>6547</th>\n",
- " <td>24/03/2020</td>\n",
- " <td>24</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>1</td>\n",
- " <td>Zimbabwe</td>\n",
- " <td>ZW</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>6548</th>\n",
- " <td>23/03/2020</td>\n",
- " <td>23</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Zimbabwe</td>\n",
- " <td>ZW</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>6549</th>\n",
- " <td>22/03/2020</td>\n",
- " <td>22</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>1</td>\n",
- " <td>0</td>\n",
- " <td>Zimbabwe</td>\n",
- " <td>ZW</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>6550</th>\n",
- " <td>21/03/2020</td>\n",
- " <td>21</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>1</td>\n",
- " <td>0</td>\n",
- " <td>Zimbabwe</td>\n",
- " <td>ZW</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "<p>6551 rows × 8 columns</p>\n",
- "</div>"
- ],
- "text/plain": [
- " DateRep Day Month Year Cases Deaths Countries and territories \\\n",
- "0 24/03/2020 24 3 2020 6 1 Afghanistan \n",
- "1 23/03/2020 23 3 2020 10 0 Afghanistan \n",
- "2 22/03/2020 22 3 2020 0 0 Afghanistan \n",
- "3 21/03/2020 21 3 2020 2 0 Afghanistan \n",
- "4 20/03/2020 20 3 2020 0 0 Afghanistan \n",
- "... ... ... ... ... ... ... ... \n",
- "6546 19/03/2020 19 3 2020 2 0 Zambia \n",
- "6547 24/03/2020 24 3 2020 0 1 Zimbabwe \n",
- "6548 23/03/2020 23 3 2020 0 0 Zimbabwe \n",
- "6549 22/03/2020 22 3 2020 1 0 Zimbabwe \n",
- "6550 21/03/2020 21 3 2020 1 0 Zimbabwe \n",
- "\n",
- " GeoId \n",
- "0 AF \n",
- "1 AF \n",
- "2 AF \n",
- "3 AF \n",
- "4 AF \n",
- "... ... \n",
- "6546 ZM \n",
- "6547 ZW \n",
- "6548 ZW \n",
- "6549 ZW \n",
- "6550 ZW \n",
- "\n",
- "[6551 rows x 8 columns]"
- ]
- },
- "execution_count": 150,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "# Reading data\n",
- "import pandas as pd\n",
- "covid_data = pd.read_csv('https://worldhealthorg-my.sharepoint.com/personal/garnicacarrenoj_who_int/_layouts/15/Doc.aspx?sourcedoc=%7B87BD9C0A-2E91-4BE3-8308-B0B545B6DFB6%7D&file=CSV%20as%20at%2024%20March%202020-Daily%20additions.csv&action=default&mobileredirect=true&CT=1585104198257&OR=ItemsView')\n",
- "covid_data"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 151,
- "metadata": {},
- "outputs": [],
- "source": [
- "from sklearn.model_selection import train_test_split \n",
- "train_set, test_set=train_test_split(covid_data,test_size=0.2,random_state=42)\n",
- "train_cp=train_set.copy()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 152,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "array([[<matplotlib.axes._subplots.AxesSubplot object at 0x13ceded90>,\n",
- " <matplotlib.axes._subplots.AxesSubplot object at 0x13caacad0>],\n",
- " [<matplotlib.axes._subplots.AxesSubplot object at 0x13cc2fd50>,\n",
- " <matplotlib.axes._subplots.AxesSubplot object at 0x13cc897d0>],\n",
- " [<matplotlib.axes._subplots.AxesSubplot object at 0x13bd9e950>,\n",
- " <matplotlib.axes._subplots.AxesSubplot object at 0x13bd2ea50>]],\n",
- " dtype=object)"
- ]
- },
- "execution_count": 152,
- "metadata": {},
- "output_type": "execute_result"
- },
- {
- "data": {
- "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEVCAYAAAAM3jVmAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nO3dfZhcZX3/8fenCAHDs9EVA5JYgzZKjRABL1BjUQhgDfRnbayFgPiLVtBasTVIL/UHpY0PaH1AJEoqKBrSKiWFCATMVr2UhwQjIUZkgaWwhgQIBAIqBr6/P+57wmGZ2Z3ZnZ2HPZ/Xdc21Z+5zzsz3nLnnu2fuc5/7KCIwM7Ny+KN2B2BmZq3jpG9mViJO+mZmJeKkb2ZWIk76ZmYl4qRvZlYiTvpmZiXipN8BJP21pFWStkraIOkHko5od1xmrSSpX9JvJT0m6RFJP5X0fknOU03kndlmkj4C/BvwL0AP8FLgq8CcdsZl1iZ/HhG7AfsDC4GPARe1N6TxxUm/jSTtAZwNnBYR34+IxyPiDxHx3xHxD5IOkfSzfNSzQdJXJO2U15WkL0jaJOlRSWslvTrPmyDpc5L+V9JGSV+TtEueN0nSlfk1N0v6sY+krNNExJaI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0EzAWWtTiGUpEUkl7e7jhKzHW+zfwdeLaWJv2I2AacDlwDrAeWRsS6Eb7csE1AHWYRgKR+Sb+V9JikRyT9VNL7JY36s5DUK+m9ow+1O/dtJxplne/Y7aqhnmbZfklPSpo0qPznOTlPGU0ADX4Hxt3+rYciohmvY3WS1A+8NyKuk7QH8Cbgi0BvRJwyytf
- "text/plain": [
- "<Figure size 432x288 with 6 Axes>"
- ]
- },
- "metadata": {
- "needs_background": "light"
- },
- "output_type": "display_data"
- }
- ],
- "source": [
- "%matplotlib inline\n",
- "covid_data.hist()\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 153,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "(77, 8)"
- ]
- },
- "execution_count": 153,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "%matplotlib inline \n",
- "import matplotlib.pyplot as plt \n",
- "covid_mexico = covid_data[covid_data['GeoId']=='MX']\n",
- "covid_mexico.shape"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 154,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "<matplotlib.axes._subplots.AxesSubplot at 0x13d347490>"
- ]
- },
- "execution_count": 154,
- "metadata": {},
- "output_type": "execute_result"
- },
- {
- "data": {
- "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEGCAYAAABiq/5QAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAWmElEQVR4nO3df5Bd5X3f8fd30SJtJGwtkqrBWohIxNiDXbE4OxRHHtc2cUNtj6Cjhtp1XLWl5Y9kHJNkguR03OCm7WClk9iedFwrQCynxJhBJmIMuGEEKW0mJlmMWH45hmDLWhXQslkZLZbWK+63f9wjsyv0467uPXs5e96vGc2957n37PneWelzHz3nPM+JzESSV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/rX19vQwOnG4SxVJqprTDfWszszHj2/MzMcjYu1p9j0P2BERZ9H8grkjM78REU8Bt0fEfwYepbn8g1o00N/HdKMxq2260WCgv69LFUmqmtMF//JTvHbKpMnMEeDSE7Q/B1x2+tJ0IiuWLWbbpvXccNwY/4pli7tdmqSKOF3wD0fEv8/MP5rZGBH/DnikvLJ0KhsH17Bh3UpGJw4z0N9n6Euak9MF//XAXRHxMV4L+iGaC7T9szIL06mtWLbYwJd0Rk4Z/Jn5IvDzEfE+4B1F8z2Z+UDplUmSStHqHbgepHk1jiSp4lxaWZJqxuCXpJox+CvKtXoknalW1+rRG4hr9Uhqhz3+inGtHkntMvgrxrV6JLXL4K8Y1+qR1C6Dv2KOrdWzpLeHcxYvYklvj2v1SJoTT+5WkGv1SGqHwV9RrtUj6Uw51CNJNWPwS1LNGPySVDMGvyTVjMEvSTVj8EtSzRj8klQzpQV/RJwfEQ9GxFMR8WR
- "text/plain": [
- "<Figure size 432x288 with 1 Axes>"
- ]
- },
- "metadata": {
- "needs_background": "light"
- },
- "output_type": "display_data"
- }
- ],
- "source": [
- "covid_mexico.plot(kind=\"scatter\", x=\"Month\", y=\"Cases\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 168,
- "metadata": {},
- "outputs": [
- {
- "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>DateRep</th>\n",
- " <th>Day</th>\n",
- " <th>Month</th>\n",
- " <th>Year</th>\n",
- " <th>Cases</th>\n",
- " <th>Deaths</th>\n",
- " <th>Countries and territories</th>\n",
- " <th>GeoId</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>3985</th>\n",
- " <td>2019-12-31</td>\n",
- " <td>31</td>\n",
- " <td>12</td>\n",
- " <td>2019</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3984</th>\n",
- " <td>2020-01-01</td>\n",
- " <td>1</td>\n",
- " <td>1</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3953</th>\n",
- " <td>2020-01-02</td>\n",
- " <td>1</td>\n",
- " <td>2</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3924</th>\n",
- " <td>2020-01-03</td>\n",
- " <td>1</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>2</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3972</th>\n",
- " <td>2020-01-13</td>\n",
- " <td>13</td>\n",
- " <td>1</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>...</th>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3974</th>\n",
- " <td>2020-11-01</td>\n",
- " <td>11</td>\n",
- " <td>1</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3943</th>\n",
- " <td>2020-11-02</td>\n",
- " <td>11</td>\n",
- " <td>2</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3973</th>\n",
- " <td>2020-12-01</td>\n",
- " <td>12</td>\n",
- " <td>1</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3942</th>\n",
- " <td>2020-12-02</td>\n",
- " <td>12</td>\n",
- " <td>2</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3921</th>\n",
- " <td>2020-12-03</td>\n",
- " <td>12</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>4</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "<p>77 rows × 8 columns</p>\n",
- "</div>"
- ],
- "text/plain": [
- " DateRep Day Month Year Cases Deaths Countries and territories \\\n",
- "3985 2019-12-31 31 12 2019 0 0 Mexico \n",
- "3984 2020-01-01 1 1 2020 0 0 Mexico \n",
- "3953 2020-01-02 1 2 2020 0 0 Mexico \n",
- "3924 2020-01-03 1 3 2020 2 0 Mexico \n",
- "3972 2020-01-13 13 1 2020 0 0 Mexico \n",
- "... ... ... ... ... ... ... ... \n",
- "3974 2020-11-01 11 1 2020 0 0 Mexico \n",
- "3943 2020-11-02 11 2 2020 0 0 Mexico \n",
- "3973 2020-12-01 12 1 2020 0 0 Mexico \n",
- "3942 2020-12-02 12 2 2020 0 0 Mexico \n",
- "3921 2020-12-03 12 3 2020 4 0 Mexico \n",
- "\n",
- " GeoId \n",
- "3985 MX \n",
- "3984 MX \n",
- "3953 MX \n",
- "3924 MX \n",
- "3972 MX \n",
- "... ... \n",
- "3974 MX \n",
- "3943 MX \n",
- "3973 MX \n",
- "3942 MX \n",
- "3921 MX \n",
- "\n",
- "[77 rows x 8 columns]"
- ]
- },
- "execution_count": 168,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "from datetime import datetime\n",
- "mexico['DateRep'] =pd.to_datetime(mexico.DateRep, format=\"%d/%m/%Y\")\n",
- "mexico_sort=mexico.sort_values(by='DateRep', ascending=True)\n",
- "mexico_sort"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": 156,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "<matplotlib.axes._subplots.AxesSubplot at 0x13ba35150>"
- ]
- },
- "execution_count": 156,
- "metadata": {},
- "output_type": "execute_result"
- },
- {
- "data": {
- "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEGCAYAAABiq/5QAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAX1UlEQVR4nO3df5Dc9X3f8edrpeV01QlzOh0aVWf5iIXtYvc4uxdsLOoaE8c/kgg6csEu42oSGrWZ4tpJWgTtZGJPmxk4zyTg/ETBjuUOdmA4u1KwDaEyxKkzJQhbOiMwBmNTnQJIvp6MjpzOJ+27f3y/F/ZOK+kk3Xd/fV6PGc3ufva7u++Pdu913/vs9/P5KiIwM7N0lBpdgJmZ1ZeD38wsMQ5+M7PEOPjNzBLj4DczS8zSRhewEKtWrYr+/v5Gl2Fm1lIef/zxH0dE7/z2lgj+/v5+du/e3egyzMxaiqTna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03AzvOsGY7A2MTU5RLc9/mcqnE2MRUgyoys0Y73Rj/Bae4r/M0j10DbM/H+UvAvRFxv6QngT+X9N+B75Ct+2MF6evuZKZSmdM2U6nQ1326t8/M2tXpgn+3pF+NiD+tbpT0b8m+tD2piBgF3lqj/TngsjMt1M5OT1cHw5sGuGneGL+/4DVL1+mC/xPAVyRdz6tBP0S2QNu/LLIwWzwbB9eyYf0qH9VjZsBpgj8iXgLeKelK4C1581cj4huFV2aLqqerw4FvZsDCz8D1MNmXsmZm1uK8tLKZWWIc/GZmiXHwm5klxsFvZpYYB39ixien2bv/sJdsMEvYQlfntDbgxdrMDLzHnwwv1mZmsxz8ifBibWY2y8GfCC/WZmazHPyJmF2sbVm5xIq
- "text/plain": [
- "<Figure size 432x288 with 1 Axes>"
- ]
- },
- "metadata": {
- "needs_background": "light"
- },
- "output_type": "display_data"
- }
- ],
- "source": [
- "mexico_filter = mexico_sort[mexico_sort['Cases']!=0]\n",
- "mexico_filter.plot(kind=\"scatter\", x=\"DateRep\", y=\"Cases\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 157,
- "metadata": {},
- "outputs": [
- {
- "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>DateRep</th>\n",
- " <th>Day</th>\n",
- " <th>Month</th>\n",
- " <th>Year</th>\n",
- " <th>Cases</th>\n",
- " <th>Deaths</th>\n",
- " <th>Countries and territories</th>\n",
- " <th>GeoId</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>3924</th>\n",
- " <td>2020-01-03</td>\n",
- " <td>1</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>2</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3923</th>\n",
- " <td>2020-02-03</td>\n",
- " <td>2</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>1</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3925</th>\n",
- " <td>2020-02-29</td>\n",
- " <td>29</td>\n",
- " <td>2</td>\n",
- " <td>2020</td>\n",
- " <td>2</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3920</th>\n",
- " <td>2020-03-13</td>\n",
- " <td>13</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>5</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3919</th>\n",
- " <td>2020-03-14</td>\n",
- " <td>14</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>10</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3918</th>\n",
- " <td>2020-03-15</td>\n",
- " <td>15</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>15</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3917</th>\n",
- " <td>2020-03-16</td>\n",
- " <td>16</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>12</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3916</th>\n",
- " <td>2020-03-17</td>\n",
- " <td>17</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>29</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3915</th>\n",
- " <td>2020-03-18</td>\n",
- " <td>18</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>11</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3914</th>\n",
- " <td>2020-03-19</td>\n",
- " <td>19</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>25</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3913</th>\n",
- " <td>2020-03-20</td>\n",
- " <td>20</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>46</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3912</th>\n",
- " <td>2020-03-21</td>\n",
- " <td>21</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>39</td>\n",
- " <td>2</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3911</th>\n",
- " <td>2020-03-22</td>\n",
- " <td>22</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>48</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3910</th>\n",
- " <td>2020-03-23</td>\n",
- " <td>23</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>65</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3909</th>\n",
- " <td>2020-03-24</td>\n",
- " <td>24</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>51</td>\n",
- " <td>2</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3922</th>\n",
- " <td>2020-09-03</td>\n",
- " <td>9</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>2</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3921</th>\n",
- " <td>2020-12-03</td>\n",
- " <td>12</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>4</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "</div>"
- ],
- "text/plain": [
- " DateRep Day Month Year Cases Deaths Countries and territories \\\n",
- "3924 2020-01-03 1 3 2020 2 0 Mexico \n",
- "3923 2020-02-03 2 3 2020 1 0 Mexico \n",
- "3925 2020-02-29 29 2 2020 2 0 Mexico \n",
- "3920 2020-03-13 13 3 2020 5 0 Mexico \n",
- "3919 2020-03-14 14 3 2020 10 0 Mexico \n",
- "3918 2020-03-15 15 3 2020 15 0 Mexico \n",
- "3917 2020-03-16 16 3 2020 12 0 Mexico \n",
- "3916 2020-03-17 17 3 2020 29 0 Mexico \n",
- "3915 2020-03-18 18 3 2020 11 0 Mexico \n",
- "3914 2020-03-19 19 3 2020 25 0 Mexico \n",
- "3913 2020-03-20 20 3 2020 46 0 Mexico \n",
- "3912 2020-03-21 21 3 2020 39 2 Mexico \n",
- "3911 2020-03-22 22 3 2020 48 0 Mexico \n",
- "3910 2020-03-23 23 3 2020 65 0 Mexico \n",
- "3909 2020-03-24 24 3 2020 51 2 Mexico \n",
- "3922 2020-09-03 9 3 2020 2 0 Mexico \n",
- "3921 2020-12-03 12 3 2020 4 0 Mexico \n",
- "\n",
- " GeoId \n",
- "3924 MX \n",
- "3923 MX \n",
- "3925 MX \n",
- "3920 MX \n",
- "3919 MX \n",
- "3918 MX \n",
- "3917 MX \n",
- "3916 MX \n",
- "3915 MX \n",
- "3914 MX \n",
- "3913 MX \n",
- "3912 MX \n",
- "3911 MX \n",
- "3910 MX \n",
- "3909 MX \n",
- "3922 MX \n",
- "3921 MX "
- ]
- },
- "execution_count": 157,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "mexico_filter.head(77)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 164,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "367"
- ]
- },
- "execution_count": 164,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "sum(mexico_filter.Cases)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 163,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "3985 2019-12-31\n",
- "3954 2020-01-31\n",
- "3955 2020-01-30\n",
- "3925 2020-02-29\n",
- "3956 2020-01-29\n",
- " ... \n",
- "3952 2020-02-02\n",
- "3983 2020-02-01\n",
- "3924 2020-01-03\n",
- "3953 2020-01-02\n",
- "3984 2020-01-01\n",
- "Name: DateRep, Length: 77, dtype: datetime64[ns]"
- ]
- },
- "execution_count": 163,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "mexico.DateRep"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 160,
- "metadata": {},
- "outputs": [],
- "source": [
- "import sklearn\n",
- "# Select a linear model\n",
- "lin_reg_model = sklearn.linear_model.LinearRegression()\n",
- "# Train the model\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 161,
- "metadata": {},
- "outputs": [
- {
- "ename": "ValueError",
- "evalue": "Expected 2D array, got 1D array instead:\narray=[ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18.\n 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36.\n 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54.\n 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72.\n 73. 74. 75. 76. 77.].\nReshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m<ipython-input-161-44b24316a33b>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mX\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlinspace\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m77\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m77\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0my\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmexico\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mCases\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mlin_reg_model\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mX\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
- "\u001b[0;32m~/lwc/topics/covid19/covid/lib/python3.7/site-packages/sklearn/linear_model/_base.py\u001b[0m in \u001b[0;36mfit\u001b[0;34m(self, X, y, sample_weight)\u001b[0m\n\u001b[1;32m 490\u001b[0m \u001b[0mn_jobs_\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mn_jobs\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 491\u001b[0m X, y = check_X_y(X, y, accept_sparse=['csr', 'csc', 'coo'],\n\u001b[0;32m--> 492\u001b[0;31m y_numeric=True, multi_output=True)\n\u001b[0m\u001b[1;32m 493\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 494\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0msample_weight\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;32m~/lwc/topics/covid19/covid/lib/python3.7/site-packages/sklearn/utils/validation.py\u001b[0m in \u001b[0;36mcheck_X_y\u001b[0;34m(X, y, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, multi_output, ensure_min_samples, ensure_min_features, y_numeric, warn_on_dtype, estimator)\u001b[0m\n\u001b[1;32m 753\u001b[0m \u001b[0mensure_min_features\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mensure_min_features\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 754\u001b[0m \u001b[0mwarn_on_dtype\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mwarn_on_dtype\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 755\u001b[0;31m estimator=estimator)\n\u001b[0m\u001b[1;32m 756\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmulti_output\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 757\u001b[0m y = check_array(y, 'csr', force_all_finite=True, ensure_2d=False,\n",
- "\u001b[0;32m~/lwc/topics/covid19/covid/lib/python3.7/site-packages/sklearn/utils/validation.py\u001b[0m in \u001b[0;36mcheck_array\u001b[0;34m(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)\u001b[0m\n\u001b[1;32m 554\u001b[0m \u001b[0;34m\"Reshape your data either using array.reshape(-1, 1) if \"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 555\u001b[0m \u001b[0;34m\"your data has a single feature or array.reshape(1, -1) \"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 556\u001b[0;31m \"if it contains a single sample.\".format(array))\n\u001b[0m\u001b[1;32m 557\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 558\u001b[0m \u001b[0;31m# in the future np.flexible dtypes will be handled like object dtypes\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;31mValueError\u001b[0m: Expected 2D array, got 1D array instead:\narray=[ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18.\n 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36.\n 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54.\n 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72.\n 73. 74. 75. 76. 77.].\nReshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample."
- ]
- }
- ],
- "source": [
- "X = np.linspace(1,77,77, axis=0)\n",
- "y = mexico.Cases\n",
- "lin_reg_model.fit(X, y)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "y.shape"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "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.7.7"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 4
- }
|