You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

937 lines
62 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 4,
  6. "metadata": {},
  7. "outputs": [],
  8. "source": [
  9. "# Reading data\n",
  10. "import os\n",
  11. "import git\n",
  12. "import shutil\n",
  13. "import tempfile\n",
  14. "\n",
  15. "# Create temporary dir\n",
  16. "t = tempfile.mkdtemp()\n",
  17. "d = 'lwc/topics/covid19/covid-model'\n",
  18. "# Clone into temporary dir\n",
  19. "git.Repo.clone_from('http://gmarx.jumpingcrab.com:8088/COVID-19/covid19-data.git', \n",
  20. " t, branch='master', depth=1)\n",
  21. "# Delete files\n",
  22. "#os.remove('README.txt')\n",
  23. "#shutil.rmtree('firstTest')\n",
  24. "#shutil.rmtree('secondTest')\n",
  25. "# Copy desired file from temporary dir\n",
  26. "shutil.move(os.path.join(t, 'data'), '.')\n",
  27. "# Remove temporary dir\n",
  28. "shutil.rmtree(t)"
  29. ]
  30. },
  31. {
  32. "cell_type": "code",
  33. "execution_count": 6,
  34. "metadata": {},
  35. "outputs": [],
  36. "source": [
  37. "import pandas as pd\n",
  38. "import numpy as np\n",
  39. "import os\n",
  40. "def loadData(path, file):\n",
  41. " csvPath=os.path.join(path, file)\n",
  42. " return pd.read_csv(csvPath)"
  43. ]
  44. },
  45. {
  46. "cell_type": "code",
  47. "execution_count": 10,
  48. "metadata": {},
  49. "outputs": [
  50. {
  51. "data": {
  52. "text/html": [
  53. "<div>\n",
  54. "<style scoped>\n",
  55. " .dataframe tbody tr th:only-of-type {\n",
  56. " vertical-align: middle;\n",
  57. " }\n",
  58. "\n",
  59. " .dataframe tbody tr th {\n",
  60. " vertical-align: top;\n",
  61. " }\n",
  62. "\n",
  63. " .dataframe thead th {\n",
  64. " text-align: right;\n",
  65. " }\n",
  66. "</style>\n",
  67. "<table border=\"1\" class=\"dataframe\">\n",
  68. " <thead>\n",
  69. " <tr style=\"text-align: right;\">\n",
  70. " <th></th>\n",
  71. " <th>Date</th>\n",
  72. " <th>Country/Region</th>\n",
  73. " <th>Province/State</th>\n",
  74. " <th>Lat</th>\n",
  75. " <th>Long</th>\n",
  76. " <th>Confirmed</th>\n",
  77. " <th>Recovered</th>\n",
  78. " <th>Deaths</th>\n",
  79. " </tr>\n",
  80. " </thead>\n",
  81. " <tbody>\n",
  82. " <tr>\n",
  83. " <th>0</th>\n",
  84. " <td>2020-01-22</td>\n",
  85. " <td>Afghanistan</td>\n",
  86. " <td>NaN</td>\n",
  87. " <td>33.0</td>\n",
  88. " <td>65.0</td>\n",
  89. " <td>0</td>\n",
  90. " <td>0.0</td>\n",
  91. " <td>0</td>\n",
  92. " </tr>\n",
  93. " <tr>\n",
  94. " <th>1</th>\n",
  95. " <td>2020-01-23</td>\n",
  96. " <td>Afghanistan</td>\n",
  97. " <td>NaN</td>\n",
  98. " <td>33.0</td>\n",
  99. " <td>65.0</td>\n",
  100. " <td>0</td>\n",
  101. " <td>0.0</td>\n",
  102. " <td>0</td>\n",
  103. " </tr>\n",
  104. " <tr>\n",
  105. " <th>2</th>\n",
  106. " <td>2020-01-24</td>\n",
  107. " <td>Afghanistan</td>\n",
  108. " <td>NaN</td>\n",
  109. " <td>33.0</td>\n",
  110. " <td>65.0</td>\n",
  111. " <td>0</td>\n",
  112. " <td>0.0</td>\n",
  113. " <td>0</td>\n",
  114. " </tr>\n",
  115. " <tr>\n",
  116. " <th>3</th>\n",
  117. " <td>2020-01-25</td>\n",
  118. " <td>Afghanistan</td>\n",
  119. " <td>NaN</td>\n",
  120. " <td>33.0</td>\n",
  121. " <td>65.0</td>\n",
  122. " <td>0</td>\n",
  123. " <td>0.0</td>\n",
  124. " <td>0</td>\n",
  125. " </tr>\n",
  126. " <tr>\n",
  127. " <th>4</th>\n",
  128. " <td>2020-01-26</td>\n",
  129. " <td>Afghanistan</td>\n",
  130. " <td>NaN</td>\n",
  131. " <td>33.0</td>\n",
  132. " <td>65.0</td>\n",
  133. " <td>0</td>\n",
  134. " <td>0.0</td>\n",
  135. " <td>0</td>\n",
  136. " </tr>\n",
  137. " </tbody>\n",
  138. "</table>\n",
  139. "</div>"
  140. ],
  141. "text/plain": [
  142. " Date Country/Region Province/State Lat Long Confirmed Recovered \\\n",
  143. "0 2020-01-22 Afghanistan NaN 33.0 65.0 0 0.0 \n",
  144. "1 2020-01-23 Afghanistan NaN 33.0 65.0 0 0.0 \n",
  145. "2 2020-01-24 Afghanistan NaN 33.0 65.0 0 0.0 \n",
  146. "3 2020-01-25 Afghanistan NaN 33.0 65.0 0 0.0 \n",
  147. "4 2020-01-26 Afghanistan NaN 33.0 65.0 0 0.0 \n",
  148. "\n",
  149. " Deaths \n",
  150. "0 0 \n",
  151. "1 0 \n",
  152. "2 0 \n",
  153. "3 0 \n",
  154. "4 0 "
  155. ]
  156. },
  157. "execution_count": 10,
  158. "metadata": {},
  159. "output_type": "execute_result"
  160. }
  161. ],
  162. "source": [
  163. "# import jtplot submodule from jupyterthemes\n",
  164. "from jupyterthemes import jtplot\n",
  165. "PATH=os.path.join(\"data\")\n",
  166. "covid_data=loadData(PATH,\"time-series-19-covid-combined.csv\")\n",
  167. "covid_data.head()"
  168. ]
  169. },
  170. {
  171. "cell_type": "code",
  172. "execution_count": 151,
  173. "metadata": {},
  174. "outputs": [],
  175. "source": [
  176. "from sklearn.model_selection import train_test_split \n",
  177. "train_set, test_set=train_test_split(covid_data,test_size=0.2,random_state=42)\n",
  178. "train_cp=train_set.copy()"
  179. ]
  180. },
  181. {
  182. "cell_type": "code",
  183. "execution_count": 11,
  184. "metadata": {},
  185. "outputs": [
  186. {
  187. "data": {
  188. "text/plain": [
  189. "array([[<matplotlib.axes._subplots.AxesSubplot object at 0x11a434290>,\n",
  190. " <matplotlib.axes._subplots.AxesSubplot object at 0x1194add50>],\n",
  191. " [<matplotlib.axes._subplots.AxesSubplot object at 0x1194d3410>,\n",
  192. " <matplotlib.axes._subplots.AxesSubplot object at 0x1194f1a90>],\n",
  193. " [<matplotlib.axes._subplots.AxesSubplot object at 0x119516150>,\n",
  194. " <matplotlib.axes._subplots.AxesSubplot object at 0x1195337d0>]],\n",
  195. " dtype=object)"
  196. ]
  197. },
  198. "execution_count": 11,
  199. "metadata": {},
  200. "output_type": "execute_result"
  201. },
  202. {
  203. "data": {
  204. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYMAAAEICAYAAAC9E5gJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nO3deZRdZZnv8e+PGcOQhGAZEqRAaXtFaREixOWUVgwQ7Q59G2lorgQccICrtvTSINpwBRRttRFBBjUCigyCCiIaAlKNXpshcSAMxhQQJCEQICEQQDH63D/e98BO5dRw5n2qfp+19qp93j09Z9e7z7P3uydFBGZmNrZt1ukAzMys85wMzMzMycDMzJwMzMwMJwMzM8PJwMzMcDLoapK2lfQjSeskfU/SkZKu72A8yyUd0Knlmw1FUkh6eafjKCsngzaR9K+SFklaL2mVpJ9IekODsz0U6AF2ioh3RsQlETGrCeGatVzeeXhW0lOSnpD0S0kfkNTw75KkPknvbUacY4WTQRtI+hhwJvBZ0o/3S4GvAXManPVuwO8jYsMIYtiiw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T8rBzgKfzOHNzZ0URMWo64CBgKdAPzGvRMnYFbgLuBu4CPpLLJwILgWX574RcLuCsHNMdwD6Fec3N4y8D5hbK9wWW5GnOIjfnDYhjOXBAlfLNgV8D15I2mnXArXleq4H35/G2Bi7P5bcCvYV5nJjLlwIHNrp+gfHAlcDvSO3jr2v3+hqtXTvqfLvr/2D1G7gXmF34fCCwPPfPJO38bFHYBv5ESh4vA/4KPJDr/FbAacD/q3UbaHDdtXQ7aDi+TlfmJlbSzXNl2SP/s38LTGv
  205. "text/plain": [
  206. "<Figure size 432x288 with 6 Axes>"
  207. ]
  208. },
  209. "metadata": {
  210. "needs_background": "light"
  211. },
  212. "output_type": "display_data"
  213. }
  214. ],
  215. "source": [
  216. "%matplotlib inline\n",
  217. "covid_data.hist()\n"
  218. ]
  219. },
  220. {
  221. "cell_type": "code",
  222. "execution_count": 153,
  223. "metadata": {},
  224. "outputs": [
  225. {
  226. "data": {
  227. "text/plain": [
  228. "(77, 8)"
  229. ]
  230. },
  231. "execution_count": 153,
  232. "metadata": {},
  233. "output_type": "execute_result"
  234. }
  235. ],
  236. "source": [
  237. "%matplotlib inline \n",
  238. "import matplotlib.pyplot as plt \n",
  239. "covid_mexico = covid_data[covid_data['GeoId']=='MX']\n",
  240. "covid_mexico.shape"
  241. ]
  242. },
  243. {
  244. "cell_type": "code",
  245. "execution_count": 21,
  246. "metadata": {},
  247. "outputs": [
  248. {
  249. "ename": "ImportError",
  250. "evalue": "The descartes package is required for plotting polygons in geopandas. You can install it using 'conda install -c conda-forge descartes' or 'pip install descartes'.",
  251. "output_type": "error",
  252. "traceback": [
  253. "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
  254. "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
  255. "\u001b[0;32m~/lwc/topics/covid19/covid/lib/python3.7/site-packages/geopandas/plotting.py\u001b[0m in \u001b[0;36mplot_polygon_collection\u001b[0;34m(ax, geoms, values, color, cmap, vmin, vmax, **kwargs)\u001b[0m\n\u001b[1;32m 80\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 81\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mdescartes\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpatch\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mPolygonPatch\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 82\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mImportError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
  256. "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'descartes'",
  257. "\nDuring handling of the above exception, another exception occurred:\n",
  258. "\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
  259. "\u001b[0;32m<ipython-input-21-0ad2a8a84de6>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mgeopandas\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mgpd\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mworld\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mgpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread_file\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdatasets\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_path\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'naturalearth_lowres'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mworld\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mplot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
  260. "\u001b[0;32m~/lwc/topics/covid19/covid/lib/python3.7/site-packages/geopandas/geodataframe.py\u001b[0m in \u001b[0;36mplot\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 654\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mthere\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 655\u001b[0m \"\"\"\n\u001b[0;32m--> 656\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mplot_dataframe\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 657\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 658\u001b[0m \u001b[0mplot\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__doc__\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mplot_dataframe\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__doc__\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
  261. "\u001b[0;32m~/lwc/topics/covid19/covid/lib/python3.7/site-packages/geopandas/plotting.py\u001b[0m in \u001b[0;36mplot_dataframe\u001b[0;34m(df, column, cmap, color, ax, cax, categorical, legend, scheme, k, vmin, vmax, markersize, figsize, legend_kwds, classification_kwds, missing_kwds, **style_kwds)\u001b[0m\n\u001b[1;32m 545\u001b[0m \u001b[0mfigsize\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mfigsize\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 546\u001b[0m \u001b[0mmarkersize\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmarkersize\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 547\u001b[0;31m \u001b[0;34m**\u001b[0m\u001b[0mstyle_kwds\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 548\u001b[0m )\n\u001b[1;32m 549\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
  262. "\u001b[0;32m~/lwc/topics/covid19/covid/lib/python3.7/site-packages/geopandas/plotting.py\u001b[0m in \u001b[0;36mplot_series\u001b[0;34m(s, cmap, color, ax, figsize, **style_kwds)\u001b[0m\n\u001b[1;32m 371\u001b[0m \u001b[0mvalues_\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvalues\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mpoly_idx\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mcmap\u001b[0m \u001b[0;32melse\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 372\u001b[0m plot_polygon_collection(\n\u001b[0;32m--> 373\u001b[0;31m \u001b[0max\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpolys\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalues_\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfacecolor\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mfacecolor\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcmap\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mcmap\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mstyle_kwds\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 374\u001b[0m )\n\u001b[1;32m 375\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
  263. "\u001b[0;32m~/lwc/topics/covid19/covid/lib/python3.7/site-packages/geopandas/plotting.py\u001b[0m in \u001b[0;36mplot_polygon_collection\u001b[0;34m(ax, geoms, values, color, cmap, vmin, vmax, **kwargs)\u001b[0m\n\u001b[1;32m 82\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mImportError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 83\u001b[0m raise ImportError(\n\u001b[0;32m---> 84\u001b[0;31m \u001b[0;34m\"The descartes package is required for plotting polygons in geopandas. \"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 85\u001b[0m \u001b[0;34m\"You can install it using 'conda install -c conda-forge descartes' or \"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 86\u001b[0m \u001b[0;34m\"'pip install descartes'.\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
  264. "\u001b[0;31mImportError\u001b[0m: The descartes package is required for plotting polygons in geopandas. You can install it using 'conda install -c conda-forge descartes' or 'pip install descartes'."
  265. ]
  266. },
  267. {
  268. "data": {
  269. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQYAAAD8CAYAAACVSwr3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdG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WrVkB/mR8+4+Af6uqmt2YkuZp6keJ8TmD24F7gYuAT1TVySR3AatVtQL8M/DpJGvADxnFY5qj5zH3ImynebfTrLC95t1Os8I5zhv/YZe0nlc+SmoMg6Rmy8OwnS6nHjDr+5KcSvJoki8neeMi5pyY5yXnnVj3jiSVZGFfsw2ZNck7x6/vySSfmfeM62aZ9l54Q5L7kjw8fj/ctIg5x7N8IsnTm10XlJGPjf+WR5NcM/VBq2rLfhidrPw28CbgYuAbwN51a/4M+Pj49kHgc1s503nO+nvAL41vv3tRsw6dd7zuUuB+4ASwfKHOCuwBHgZ+Zbz9ugv5tWV0Uu/d49t7ge8ucN7fBa4BHtvk/puALwEBrgMemPaYW33EsJ0up546a1XdV1U/Hm+eYHRNx6IMeW0BPsTo/678ZJ7DrTNk1tuAI1X1LEBVPT3nGScNmbeAV41vvxr43hzne/EgVfcz+jZwMweAT9XICeA1SV7/Uo+51WHY6HLqnZutqarngRcup563IbNOupVRhRdl6rzjQ8bdVfXFeQ62gSGv7ZXAlUm+muREkn1zm64bMu8HgZuTnAGOA++dz2jn5OW+t+d7SfT/F0luBpaBty16ls0keQXwUeCWBY8y1A5GHyeuZ3Qkdn+S36iq/1roVJs7BNxdVX+b5HcYXcfzlqr670UPNgtbfcSwnS6nHjIrSW4APgDsr6qfzmm2jUyb91LgLcBXknyX0WfLlQWdgBz
  270. "text/plain": [
  271. "<Figure size 432x288 with 1 Axes>"
  272. ]
  273. },
  274. "metadata": {
  275. "needs_background": "light"
  276. },
  277. "output_type": "display_data"
  278. }
  279. ],
  280. "source": [
  281. "import geopandas as gpd\n",
  282. "world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))\n",
  283. "world.plot()"
  284. ]
  285. },
  286. {
  287. "cell_type": "code",
  288. "execution_count": null,
  289. "metadata": {},
  290. "outputs": [],
  291. "source": [
  292. "covid_data.plot(kind=\"scatter\", x=\"Long\", y=\"Lat\")"
  293. ]
  294. },
  295. {
  296. "cell_type": "code",
  297. "execution_count": 168,
  298. "metadata": {},
  299. "outputs": [
  300. {
  301. "data": {
  302. "text/html": [
  303. "<div>\n",
  304. "<style scoped>\n",
  305. " .dataframe tbody tr th:only-of-type {\n",
  306. " vertical-align: middle;\n",
  307. " }\n",
  308. "\n",
  309. " .dataframe tbody tr th {\n",
  310. " vertical-align: top;\n",
  311. " }\n",
  312. "\n",
  313. " .dataframe thead th {\n",
  314. " text-align: right;\n",
  315. " }\n",
  316. "</style>\n",
  317. "<table border=\"1\" class=\"dataframe\">\n",
  318. " <thead>\n",
  319. " <tr style=\"text-align: right;\">\n",
  320. " <th></th>\n",
  321. " <th>DateRep</th>\n",
  322. " <th>Day</th>\n",
  323. " <th>Month</th>\n",
  324. " <th>Year</th>\n",
  325. " <th>Cases</th>\n",
  326. " <th>Deaths</th>\n",
  327. " <th>Countries and territories</th>\n",
  328. " <th>GeoId</th>\n",
  329. " </tr>\n",
  330. " </thead>\n",
  331. " <tbody>\n",
  332. " <tr>\n",
  333. " <th>3985</th>\n",
  334. " <td>2019-12-31</td>\n",
  335. " <td>31</td>\n",
  336. " <td>12</td>\n",
  337. " <td>2019</td>\n",
  338. " <td>0</td>\n",
  339. " <td>0</td>\n",
  340. " <td>Mexico</td>\n",
  341. " <td>MX</td>\n",
  342. " </tr>\n",
  343. " <tr>\n",
  344. " <th>3984</th>\n",
  345. " <td>2020-01-01</td>\n",
  346. " <td>1</td>\n",
  347. " <td>1</td>\n",
  348. " <td>2020</td>\n",
  349. " <td>0</td>\n",
  350. " <td>0</td>\n",
  351. " <td>Mexico</td>\n",
  352. " <td>MX</td>\n",
  353. " </tr>\n",
  354. " <tr>\n",
  355. " <th>3953</th>\n",
  356. " <td>2020-01-02</td>\n",
  357. " <td>1</td>\n",
  358. " <td>2</td>\n",
  359. " <td>2020</td>\n",
  360. " <td>0</td>\n",
  361. " <td>0</td>\n",
  362. " <td>Mexico</td>\n",
  363. " <td>MX</td>\n",
  364. " </tr>\n",
  365. " <tr>\n",
  366. " <th>3924</th>\n",
  367. " <td>2020-01-03</td>\n",
  368. " <td>1</td>\n",
  369. " <td>3</td>\n",
  370. " <td>2020</td>\n",
  371. " <td>2</td>\n",
  372. " <td>0</td>\n",
  373. " <td>Mexico</td>\n",
  374. " <td>MX</td>\n",
  375. " </tr>\n",
  376. " <tr>\n",
  377. " <th>3972</th>\n",
  378. " <td>2020-01-13</td>\n",
  379. " <td>13</td>\n",
  380. " <td>1</td>\n",
  381. " <td>2020</td>\n",
  382. " <td>0</td>\n",
  383. " <td>0</td>\n",
  384. " <td>Mexico</td>\n",
  385. " <td>MX</td>\n",
  386. " </tr>\n",
  387. " <tr>\n",
  388. " <th>...</th>\n",
  389. " <td>...</td>\n",
  390. " <td>...</td>\n",
  391. " <td>...</td>\n",
  392. " <td>...</td>\n",
  393. " <td>...</td>\n",
  394. " <td>...</td>\n",
  395. " <td>...</td>\n",
  396. " <td>...</td>\n",
  397. " </tr>\n",
  398. " <tr>\n",
  399. " <th>3974</th>\n",
  400. " <td>2020-11-01</td>\n",
  401. " <td>11</td>\n",
  402. " <td>1</td>\n",
  403. " <td>2020</td>\n",
  404. " <td>0</td>\n",
  405. " <td>0</td>\n",
  406. " <td>Mexico</td>\n",
  407. " <td>MX</td>\n",
  408. " </tr>\n",
  409. " <tr>\n",
  410. " <th>3943</th>\n",
  411. " <td>2020-11-02</td>\n",
  412. " <td>11</td>\n",
  413. " <td>2</td>\n",
  414. " <td>2020</td>\n",
  415. " <td>0</td>\n",
  416. " <td>0</td>\n",
  417. " <td>Mexico</td>\n",
  418. " <td>MX</td>\n",
  419. " </tr>\n",
  420. " <tr>\n",
  421. " <th>3973</th>\n",
  422. " <td>2020-12-01</td>\n",
  423. " <td>12</td>\n",
  424. " <td>1</td>\n",
  425. " <td>2020</td>\n",
  426. " <td>0</td>\n",
  427. " <td>0</td>\n",
  428. " <td>Mexico</td>\n",
  429. " <td>MX</td>\n",
  430. " </tr>\n",
  431. " <tr>\n",
  432. " <th>3942</th>\n",
  433. " <td>2020-12-02</td>\n",
  434. " <td>12</td>\n",
  435. " <td>2</td>\n",
  436. " <td>2020</td>\n",
  437. " <td>0</td>\n",
  438. " <td>0</td>\n",
  439. " <td>Mexico</td>\n",
  440. " <td>MX</td>\n",
  441. " </tr>\n",
  442. " <tr>\n",
  443. " <th>3921</th>\n",
  444. " <td>2020-12-03</td>\n",
  445. " <td>12</td>\n",
  446. " <td>3</td>\n",
  447. " <td>2020</td>\n",
  448. " <td>4</td>\n",
  449. " <td>0</td>\n",
  450. " <td>Mexico</td>\n",
  451. " <td>MX</td>\n",
  452. " </tr>\n",
  453. " </tbody>\n",
  454. "</table>\n",
  455. "<p>77 rows × 8 columns</p>\n",
  456. "</div>"
  457. ],
  458. "text/plain": [
  459. " DateRep Day Month Year Cases Deaths Countries and territories \\\n",
  460. "3985 2019-12-31 31 12 2019 0 0 Mexico \n",
  461. "3984 2020-01-01 1 1 2020 0 0 Mexico \n",
  462. "3953 2020-01-02 1 2 2020 0 0 Mexico \n",
  463. "3924 2020-01-03 1 3 2020 2 0 Mexico \n",
  464. "3972 2020-01-13 13 1 2020 0 0 Mexico \n",
  465. "... ... ... ... ... ... ... ... \n",
  466. "3974 2020-11-01 11 1 2020 0 0 Mexico \n",
  467. "3943 2020-11-02 11 2 2020 0 0 Mexico \n",
  468. "3973 2020-12-01 12 1 2020 0 0 Mexico \n",
  469. "3942 2020-12-02 12 2 2020 0 0 Mexico \n",
  470. "3921 2020-12-03 12 3 2020 4 0 Mexico \n",
  471. "\n",
  472. " GeoId \n",
  473. "3985 MX \n",
  474. "3984 MX \n",
  475. "3953 MX \n",
  476. "3924 MX \n",
  477. "3972 MX \n",
  478. "... ... \n",
  479. "3974 MX \n",
  480. "3943 MX \n",
  481. "3973 MX \n",
  482. "3942 MX \n",
  483. "3921 MX \n",
  484. "\n",
  485. "[77 rows x 8 columns]"
  486. ]
  487. },
  488. "execution_count": 168,
  489. "metadata": {},
  490. "output_type": "execute_result"
  491. }
  492. ],
  493. "source": [
  494. "from datetime import datetime\n",
  495. "mexico['DateRep'] =pd.to_datetime(mexico.DateRep, format=\"%d/%m/%Y\")\n",
  496. "mexico_sort=mexico.sort_values(by='DateRep', ascending=True)\n",
  497. "mexico_sort"
  498. ]
  499. },
  500. {
  501. "cell_type": "code",
  502. "execution_count": null,
  503. "metadata": {},
  504. "outputs": [],
  505. "source": []
  506. },
  507. {
  508. "cell_type": "code",
  509. "execution_count": 156,
  510. "metadata": {},
  511. "outputs": [
  512. {
  513. "data": {
  514. "text/plain": [
  515. "<matplotlib.axes._subplots.AxesSubplot at 0x13ba35150>"
  516. ]
  517. },
  518. "execution_count": 156,
  519. "metadata": {},
  520. "output_type": "execute_result"
  521. },
  522. {
  523. "data": {
  524. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEGCAYAAABiq/5QAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAX1UlEQVR4nO3df5Dc9X3f8edrpeV01QlzOh0aVWf5iIXtYvc4uxdsLOoaE8c/kgg6csEu42oSGrWZ4tpJWgTtZGJPmxk4zyTg/ETBjuUOdmA4u1KwDaEyxKkzJQhbOiMwBmNTnQJIvp6MjpzOJ+27f3y/F/ZOK+kk3Xd/fV6PGc3ufva7u++Pdu913/vs9/P5KiIwM7N0lBpdgJmZ1ZeD38wsMQ5+M7PEOPjNzBLj4DczS8zSRhewEKtWrYr+/v5Gl2Fm1lIef/zxH0dE7/z2lgj+/v5+du/e3egyzMxaiqTna7V7qMfMLDEOfjOzxDj4zcwS4+A3M0uMg9/MLDEO/sSNT06zd/9hxienG12KmdVJSxzOacXYsecAW0dGKZdKzFQqDG8aYOPg2kaXZWYF8x5/osYnp9k6MsrRmQpHpo9xdKbCTSOj3vM3S4CDP1FjE1OUS3Pf/nKpxNjEVIMqMrN6cfAnqq+7k5lK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AVyRdz6tBP0S2QNu/LLIwWzwbB9eyYf0qH9VjZsBpgj8iXgLeKelK4C1581cj4huFV2aLqqerw4FvZsDCz8D1MNmXsmZm1uK8tLKZWWIc/GZmiXHwm5klxsFvZpYYB39ixien2bv/sJdsMEvYQlfntDbgxdrMDLzHnwwv1mZmsxz8ifBibWY2y8GfCC/WZmazHPyJmF2sbVm5xIq
  525. "text/plain": [
  526. "<Figure size 432x288 with 1 Axes>"
  527. ]
  528. },
  529. "metadata": {
  530. "needs_background": "light"
  531. },
  532. "output_type": "display_data"
  533. }
  534. ],
  535. "source": [
  536. "mexico_filter = mexico_sort[mexico_sort['Cases']!=0]\n",
  537. "mexico_filter.plot(kind=\"scatter\", x=\"DateRep\", y=\"Cases\")"
  538. ]
  539. },
  540. {
  541. "cell_type": "code",
  542. "execution_count": 157,
  543. "metadata": {},
  544. "outputs": [
  545. {
  546. "data": {
  547. "text/html": [
  548. "<div>\n",
  549. "<style scoped>\n",
  550. " .dataframe tbody tr th:only-of-type {\n",
  551. " vertical-align: middle;\n",
  552. " }\n",
  553. "\n",
  554. " .dataframe tbody tr th {\n",
  555. " vertical-align: top;\n",
  556. " }\n",
  557. "\n",
  558. " .dataframe thead th {\n",
  559. " text-align: right;\n",
  560. " }\n",
  561. "</style>\n",
  562. "<table border=\"1\" class=\"dataframe\">\n",
  563. " <thead>\n",
  564. " <tr style=\"text-align: right;\">\n",
  565. " <th></th>\n",
  566. " <th>DateRep</th>\n",
  567. " <th>Day</th>\n",
  568. " <th>Month</th>\n",
  569. " <th>Year</th>\n",
  570. " <th>Cases</th>\n",
  571. " <th>Deaths</th>\n",
  572. " <th>Countries and territories</th>\n",
  573. " <th>GeoId</th>\n",
  574. " </tr>\n",
  575. " </thead>\n",
  576. " <tbody>\n",
  577. " <tr>\n",
  578. " <th>3924</th>\n",
  579. " <td>2020-01-03</td>\n",
  580. " <td>1</td>\n",
  581. " <td>3</td>\n",
  582. " <td>2020</td>\n",
  583. " <td>2</td>\n",
  584. " <td>0</td>\n",
  585. " <td>Mexico</td>\n",
  586. " <td>MX</td>\n",
  587. " </tr>\n",
  588. " <tr>\n",
  589. " <th>3923</th>\n",
  590. " <td>2020-02-03</td>\n",
  591. " <td>2</td>\n",
  592. " <td>3</td>\n",
  593. " <td>2020</td>\n",
  594. " <td>1</td>\n",
  595. " <td>0</td>\n",
  596. " <td>Mexico</td>\n",
  597. " <td>MX</td>\n",
  598. " </tr>\n",
  599. " <tr>\n",
  600. " <th>3925</th>\n",
  601. " <td>2020-02-29</td>\n",
  602. " <td>29</td>\n",
  603. " <td>2</td>\n",
  604. " <td>2020</td>\n",
  605. " <td>2</td>\n",
  606. " <td>0</td>\n",
  607. " <td>Mexico</td>\n",
  608. " <td>MX</td>\n",
  609. " </tr>\n",
  610. " <tr>\n",
  611. " <th>3920</th>\n",
  612. " <td>2020-03-13</td>\n",
  613. " <td>13</td>\n",
  614. " <td>3</td>\n",
  615. " <td>2020</td>\n",
  616. " <td>5</td>\n",
  617. " <td>0</td>\n",
  618. " <td>Mexico</td>\n",
  619. " <td>MX</td>\n",
  620. " </tr>\n",
  621. " <tr>\n",
  622. " <th>3919</th>\n",
  623. " <td>2020-03-14</td>\n",
  624. " <td>14</td>\n",
  625. " <td>3</td>\n",
  626. " <td>2020</td>\n",
  627. " <td>10</td>\n",
  628. " <td>0</td>\n",
  629. " <td>Mexico</td>\n",
  630. " <td>MX</td>\n",
  631. " </tr>\n",
  632. " <tr>\n",
  633. " <th>3918</th>\n",
  634. " <td>2020-03-15</td>\n",
  635. " <td>15</td>\n",
  636. " <td>3</td>\n",
  637. " <td>2020</td>\n",
  638. " <td>15</td>\n",
  639. " <td>0</td>\n",
  640. " <td>Mexico</td>\n",
  641. " <td>MX</td>\n",
  642. " </tr>\n",
  643. " <tr>\n",
  644. " <th>3917</th>\n",
  645. " <td>2020-03-16</td>\n",
  646. " <td>16</td>\n",
  647. " <td>3</td>\n",
  648. " <td>2020</td>\n",
  649. " <td>12</td>\n",
  650. " <td>0</td>\n",
  651. " <td>Mexico</td>\n",
  652. " <td>MX</td>\n",
  653. " </tr>\n",
  654. " <tr>\n",
  655. " <th>3916</th>\n",
  656. " <td>2020-03-17</td>\n",
  657. " <td>17</td>\n",
  658. " <td>3</td>\n",
  659. " <td>2020</td>\n",
  660. " <td>29</td>\n",
  661. " <td>0</td>\n",
  662. " <td>Mexico</td>\n",
  663. " <td>MX</td>\n",
  664. " </tr>\n",
  665. " <tr>\n",
  666. " <th>3915</th>\n",
  667. " <td>2020-03-18</td>\n",
  668. " <td>18</td>\n",
  669. " <td>3</td>\n",
  670. " <td>2020</td>\n",
  671. " <td>11</td>\n",
  672. " <td>0</td>\n",
  673. " <td>Mexico</td>\n",
  674. " <td>MX</td>\n",
  675. " </tr>\n",
  676. " <tr>\n",
  677. " <th>3914</th>\n",
  678. " <td>2020-03-19</td>\n",
  679. " <td>19</td>\n",
  680. " <td>3</td>\n",
  681. " <td>2020</td>\n",
  682. " <td>25</td>\n",
  683. " <td>0</td>\n",
  684. " <td>Mexico</td>\n",
  685. " <td>MX</td>\n",
  686. " </tr>\n",
  687. " <tr>\n",
  688. " <th>3913</th>\n",
  689. " <td>2020-03-20</td>\n",
  690. " <td>20</td>\n",
  691. " <td>3</td>\n",
  692. " <td>2020</td>\n",
  693. " <td>46</td>\n",
  694. " <td>0</td>\n",
  695. " <td>Mexico</td>\n",
  696. " <td>MX</td>\n",
  697. " </tr>\n",
  698. " <tr>\n",
  699. " <th>3912</th>\n",
  700. " <td>2020-03-21</td>\n",
  701. " <td>21</td>\n",
  702. " <td>3</td>\n",
  703. " <td>2020</td>\n",
  704. " <td>39</td>\n",
  705. " <td>2</td>\n",
  706. " <td>Mexico</td>\n",
  707. " <td>MX</td>\n",
  708. " </tr>\n",
  709. " <tr>\n",
  710. " <th>3911</th>\n",
  711. " <td>2020-03-22</td>\n",
  712. " <td>22</td>\n",
  713. " <td>3</td>\n",
  714. " <td>2020</td>\n",
  715. " <td>48</td>\n",
  716. " <td>0</td>\n",
  717. " <td>Mexico</td>\n",
  718. " <td>MX</td>\n",
  719. " </tr>\n",
  720. " <tr>\n",
  721. " <th>3910</th>\n",
  722. " <td>2020-03-23</td>\n",
  723. " <td>23</td>\n",
  724. " <td>3</td>\n",
  725. " <td>2020</td>\n",
  726. " <td>65</td>\n",
  727. " <td>0</td>\n",
  728. " <td>Mexico</td>\n",
  729. " <td>MX</td>\n",
  730. " </tr>\n",
  731. " <tr>\n",
  732. " <th>3909</th>\n",
  733. " <td>2020-03-24</td>\n",
  734. " <td>24</td>\n",
  735. " <td>3</td>\n",
  736. " <td>2020</td>\n",
  737. " <td>51</td>\n",
  738. " <td>2</td>\n",
  739. " <td>Mexico</td>\n",
  740. " <td>MX</td>\n",
  741. " </tr>\n",
  742. " <tr>\n",
  743. " <th>3922</th>\n",
  744. " <td>2020-09-03</td>\n",
  745. " <td>9</td>\n",
  746. " <td>3</td>\n",
  747. " <td>2020</td>\n",
  748. " <td>2</td>\n",
  749. " <td>0</td>\n",
  750. " <td>Mexico</td>\n",
  751. " <td>MX</td>\n",
  752. " </tr>\n",
  753. " <tr>\n",
  754. " <th>3921</th>\n",
  755. " <td>2020-12-03</td>\n",
  756. " <td>12</td>\n",
  757. " <td>3</td>\n",
  758. " <td>2020</td>\n",
  759. " <td>4</td>\n",
  760. " <td>0</td>\n",
  761. " <td>Mexico</td>\n",
  762. " <td>MX</td>\n",
  763. " </tr>\n",
  764. " </tbody>\n",
  765. "</table>\n",
  766. "</div>"
  767. ],
  768. "text/plain": [
  769. " DateRep Day Month Year Cases Deaths Countries and territories \\\n",
  770. "3924 2020-01-03 1 3 2020 2 0 Mexico \n",
  771. "3923 2020-02-03 2 3 2020 1 0 Mexico \n",
  772. "3925 2020-02-29 29 2 2020 2 0 Mexico \n",
  773. "3920 2020-03-13 13 3 2020 5 0 Mexico \n",
  774. "3919 2020-03-14 14 3 2020 10 0 Mexico \n",
  775. "3918 2020-03-15 15 3 2020 15 0 Mexico \n",
  776. "3917 2020-03-16 16 3 2020 12 0 Mexico \n",
  777. "3916 2020-03-17 17 3 2020 29 0 Mexico \n",
  778. "3915 2020-03-18 18 3 2020 11 0 Mexico \n",
  779. "3914 2020-03-19 19 3 2020 25 0 Mexico \n",
  780. "3913 2020-03-20 20 3 2020 46 0 Mexico \n",
  781. "3912 2020-03-21 21 3 2020 39 2 Mexico \n",
  782. "3911 2020-03-22 22 3 2020 48 0 Mexico \n",
  783. "3910 2020-03-23 23 3 2020 65 0 Mexico \n",
  784. "3909 2020-03-24 24 3 2020 51 2 Mexico \n",
  785. "3922 2020-09-03 9 3 2020 2 0 Mexico \n",
  786. "3921 2020-12-03 12 3 2020 4 0 Mexico \n",
  787. "\n",
  788. " GeoId \n",
  789. "3924 MX \n",
  790. "3923 MX \n",
  791. "3925 MX \n",
  792. "3920 MX \n",
  793. "3919 MX \n",
  794. "3918 MX \n",
  795. "3917 MX \n",
  796. "3916 MX \n",
  797. "3915 MX \n",
  798. "3914 MX \n",
  799. "3913 MX \n",
  800. "3912 MX \n",
  801. "3911 MX \n",
  802. "3910 MX \n",
  803. "3909 MX \n",
  804. "3922 MX \n",
  805. "3921 MX "
  806. ]
  807. },
  808. "execution_count": 157,
  809. "metadata": {},
  810. "output_type": "execute_result"
  811. }
  812. ],
  813. "source": [
  814. "mexico_filter.head(77)"
  815. ]
  816. },
  817. {
  818. "cell_type": "code",
  819. "execution_count": 164,
  820. "metadata": {},
  821. "outputs": [
  822. {
  823. "data": {
  824. "text/plain": [
  825. "367"
  826. ]
  827. },
  828. "execution_count": 164,
  829. "metadata": {},
  830. "output_type": "execute_result"
  831. }
  832. ],
  833. "source": [
  834. "sum(mexico_filter.Cases)"
  835. ]
  836. },
  837. {
  838. "cell_type": "code",
  839. "execution_count": 163,
  840. "metadata": {},
  841. "outputs": [
  842. {
  843. "data": {
  844. "text/plain": [
  845. "3985 2019-12-31\n",
  846. "3954 2020-01-31\n",
  847. "3955 2020-01-30\n",
  848. "3925 2020-02-29\n",
  849. "3956 2020-01-29\n",
  850. " ... \n",
  851. "3952 2020-02-02\n",
  852. "3983 2020-02-01\n",
  853. "3924 2020-01-03\n",
  854. "3953 2020-01-02\n",
  855. "3984 2020-01-01\n",
  856. "Name: DateRep, Length: 77, dtype: datetime64[ns]"
  857. ]
  858. },
  859. "execution_count": 163,
  860. "metadata": {},
  861. "output_type": "execute_result"
  862. }
  863. ],
  864. "source": [
  865. "mexico.DateRep"
  866. ]
  867. },
  868. {
  869. "cell_type": "code",
  870. "execution_count": 160,
  871. "metadata": {},
  872. "outputs": [],
  873. "source": [
  874. "import sklearn\n",
  875. "# Select a linear model\n",
  876. "lin_reg_model = sklearn.linear_model.LinearRegression()\n",
  877. "# Train the model\n"
  878. ]
  879. },
  880. {
  881. "cell_type": "code",
  882. "execution_count": 161,
  883. "metadata": {},
  884. "outputs": [
  885. {
  886. "ename": "ValueError",
  887. "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.",
  888. "output_type": "error",
  889. "traceback": [
  890. "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
  891. "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
  892. "\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",
  893. "\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",
  894. "\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",
  895. "\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",
  896. "\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."
  897. ]
  898. }
  899. ],
  900. "source": [
  901. "X = np.linspace(1,77,77, axis=0)\n",
  902. "y = mexico.Cases\n",
  903. "lin_reg_model.fit(X, y)"
  904. ]
  905. },
  906. {
  907. "cell_type": "code",
  908. "execution_count": null,
  909. "metadata": {},
  910. "outputs": [],
  911. "source": [
  912. "y.shape"
  913. ]
  914. }
  915. ],
  916. "metadata": {
  917. "kernelspec": {
  918. "display_name": "Python 3",
  919. "language": "python",
  920. "name": "python3"
  921. },
  922. "language_info": {
  923. "codemirror_mode": {
  924. "name": "ipython",
  925. "version": 3
  926. },
  927. "file_extension": ".py",
  928. "mimetype": "text/x-python",
  929. "name": "python",
  930. "nbconvert_exporter": "python",
  931. "pygments_lexer": "ipython3",
  932. "version": "3.7.7"
  933. }
  934. },
  935. "nbformat": 4,
  936. "nbformat_minor": 4
  937. }