diff --git a/.ipynb_checkpoints/ufos-checkpoint.ipynb b/.ipynb_checkpoints/ufos-checkpoint.ipynb new file mode 100644 index 0000000..a61e327 --- /dev/null +++ b/.ipynb_checkpoints/ufos-checkpoint.ipynb @@ -0,0 +1,154 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# UFO Question \n", + "\n", + "Our data science team has predicted that the Earth is going to be invaded by an alien force in the\n", + "next years. Our only hope is to replicate a device that can block all alien technology in a radius of\n", + "~300km. Sadly, the device was sold in 2004 to an anonymous buyer to protect her hometown and\n", + "we don't know how contact her again. We know that the device has been active since 2004 in one\n", + "city in the USA, and we want to know where to start our search.\n", + "We've included a dataset called ​ufo.csv​. This dataset contains over 80,000 reports of UFO sightings\n", + "over the last century (all of them verified by the ESA). Using this dataset, try to guess the city in\n", + "which the device has been hidden.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting folium\n", + " Downloading folium-0.12.1-py2.py3-none-any.whl (94 kB)\n", + "Requirement already satisfied: numpy in c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from folium) (1.20.2)\n", + "Requirement already satisfied: jinja2>=2.9 in c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from folium) (2.11.3)\n", + "Collecting branca>=0.3.0\n", + " Downloading branca-0.4.2-py3-none-any.whl (24 kB)\n", + "Requirement already satisfied: requests in c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from folium) (2.25.1)\n", + "Requirement already satisfied: MarkupSafe>=0.23 in c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from jinja2>=2.9->folium) (1.1.1)\n", + "Requirement already satisfied: idna<3,>=2.5 in c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from requests->folium) (2.10)\n", + "Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from requests->folium) (1.26.4)\n", + "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from requests->folium) (2020.12.5)\n", + "Requirement already satisfied: chardet<5,>=3.0.2 in c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from requests->folium) (4.0.0)\n", + "Installing collected packages: branca, folium\n", + "Successfully installed branca-0.4.2 folium-0.12.1\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING: You are using pip version 20.2.3; however, version 21.1.2 is available.\n", + "You should consider upgrading via the 'c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\python.exe -m pip install --upgrade pip' command.\n" + ] + } + ], + "source": [ + "!pip install folium" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "# Import libraries\n", + "import pandas as pd\n", + "import folium\n", + "from folium import plugins" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "# Import data\n", + "ufo=pd.read_csv(\"ufo.csv\")" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [], + "source": [ + "# Select data\n", + "filtered=ufo[(ufo[\"country\"]==\"us\") & (ufo[\"year\"] >= 2004)]" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [], + "source": [ + "# Create a map\n", + "mapa =folium.Map([40.732029, -73.988129], zoom_start=11)" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
Make this Notebook Trusted to load map: File -> Trust Notebook
" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Find the city\n", + "cites = filtered[['latitude', 'longitude']].values\n", + "mapa.add_child(folium.plugins.HeatMap(cites, radius=15))\n", + "mapa" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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.9.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ufos.ipynb b/ufos.ipynb index f539d1a..a61e327 100755 --- a/ufos.ipynb +++ b/ufos.ipynb @@ -18,39 +18,116 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting folium\n", + " Downloading folium-0.12.1-py2.py3-none-any.whl (94 kB)\n", + "Requirement already satisfied: numpy in c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from folium) (1.20.2)\n", + "Requirement already satisfied: jinja2>=2.9 in c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from folium) (2.11.3)\n", + "Collecting branca>=0.3.0\n", + " Downloading branca-0.4.2-py3-none-any.whl (24 kB)\n", + "Requirement already satisfied: requests in c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from folium) (2.25.1)\n", + "Requirement already satisfied: MarkupSafe>=0.23 in c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from jinja2>=2.9->folium) (1.1.1)\n", + "Requirement already satisfied: idna<3,>=2.5 in c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from requests->folium) (2.10)\n", + "Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from requests->folium) (1.26.4)\n", + "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from requests->folium) (2020.12.5)\n", + "Requirement already satisfied: chardet<5,>=3.0.2 in c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\lib\\site-packages (from requests->folium) (4.0.0)\n", + "Installing collected packages: branca, folium\n", + "Successfully installed branca-0.4.2 folium-0.12.1\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING: You are using pip version 20.2.3; however, version 21.1.2 is available.\n", + "You should consider upgrading via the 'c:\\users\\atefe\\appdata\\local\\programs\\python\\python39\\python.exe -m pip install --upgrade pip' command.\n" + ] + } + ], + "source": [ + "!pip install folium" + ] + }, + { + "cell_type": "code", + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ - "# Import libraries" + "# Import libraries\n", + "import pandas as pd\n", + "import folium\n", + "from folium import plugins" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ - "# Import data" + "# Import data\n", + "ufo=pd.read_csv(\"ufo.csv\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ - "# Select data" + "# Select data\n", + "filtered=ufo[(ufo[\"country\"]==\"us\") & (ufo[\"year\"] >= 2004)]" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ - "# Find the city" + "# Create a map\n", + "mapa =folium.Map([40.732029, -73.988129], zoom_start=11)" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
Make this Notebook Trusted to load map: File -> Trust Notebook
" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Find the city\n", + "cites = filtered[['latitude', 'longitude']].values\n", + "mapa.add_child(folium.plugins.HeatMap(cites, radius=15))\n", + "mapa" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -69,7 +146,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.4" + "version": "3.9.2" } }, "nbformat": 4,