-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:rekhaamer/DataViz-Project-1
- Loading branch information
Showing
3 changed files
with
1,039 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
key='f82cbd3246ce4e0cbea21492a3d25188' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 78, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import gmaps\n", | ||
"import pandas as pd\n", | ||
"\n", | ||
"gkey=\"Googlemapskey\"\n", | ||
"gmaps.configure(api_key=gkey)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 90, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"City object\n", | ||
"Lat object\n", | ||
"Lng object\n", | ||
"Vader object\n", | ||
"dtype: object" | ||
] | ||
}, | ||
"execution_count": 90, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"df = pd.DataFrame({\n", | ||
" 'City': ['Guttenberg ', 'Union City','New York City','San Jose','Los Angeles','Chicago','Houston',\n", | ||
" 'Philadelphia','Phoenix','San Antonio','San Diego','Dallas','Jacksonville','San Francisco'],\n", | ||
" 'Lat': ['40.7920454', '40.7795455','40.712775','37.338208','34.0522342','41.8781136','29.7604267','39.9525839',\n", | ||
" '33.4483771','29.4241219','32.715738','32.7766642','30.3321838','37.7749295'],\n", | ||
" 'Lng':['-74.0037505','-74.02375119999999','-74.005973','-121.886329','-118.2436849','-87.6297982','-95.3698028',\n", | ||
" '-75.1652215','-112.0740373','-98.4936282','-117.1610838','-96.7969879','-81.655651','-122.4194155'],\n", | ||
" 'Vader':['.915','.155','.15','.8','.95','.545','.545','.857','.789','.645','.65','.897','.10','.99']})\n", | ||
"df.dtypes" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 91, | ||
"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>Lat</th>\n", | ||
" <th>Lng</th>\n", | ||
" <th>Vader</th>\n", | ||
" </tr>\n", | ||
" </thead>\n", | ||
" <tbody>\n", | ||
" <tr>\n", | ||
" <th>0</th>\n", | ||
" <td>40.792045</td>\n", | ||
" <td>-74.003750</td>\n", | ||
" <td>0.915</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>1</th>\n", | ||
" <td>40.779545</td>\n", | ||
" <td>-74.023751</td>\n", | ||
" <td>0.155</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>2</th>\n", | ||
" <td>40.712775</td>\n", | ||
" <td>-74.005973</td>\n", | ||
" <td>0.150</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>3</th>\n", | ||
" <td>37.338208</td>\n", | ||
" <td>-121.886329</td>\n", | ||
" <td>0.800</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>4</th>\n", | ||
" <td>34.052234</td>\n", | ||
" <td>-118.243685</td>\n", | ||
" <td>0.950</td>\n", | ||
" </tr>\n", | ||
" </tbody>\n", | ||
"</table>\n", | ||
"</div>" | ||
], | ||
"text/plain": [ | ||
" Lat Lng Vader\n", | ||
"0 40.792045 -74.003750 0.915\n", | ||
"1 40.779545 -74.023751 0.155\n", | ||
"2 40.712775 -74.005973 0.150\n", | ||
"3 37.338208 -121.886329 0.800\n", | ||
"4 34.052234 -118.243685 0.950" | ||
] | ||
}, | ||
"execution_count": 91, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"cleandf=pd.DataFrame({'Lat':df['Lat'].astype('float64'),'Lng':df['Lng'].astype('float64'),'Vader':df['Vader'].astype('float64')})\n", | ||
"cleandf.head()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 92, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"locations = cleandf[[\"Lat\", \"Lng\"]]\n", | ||
"ratings = cleandf[\"Vader\"]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 93, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "6b8f1a8f551e4cae96532529c087ba08", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/html": [ | ||
"<p>Failed to display Jupyter Widget of type <code>Figure</code>.</p>\n", | ||
"<p>\n", | ||
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", | ||
" that the widgets JavaScript is still loading. If this message persists, it\n", | ||
" likely means that the widgets JavaScript library is either not installed or\n", | ||
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n", | ||
" Widgets Documentation</a> for setup instructions.\n", | ||
"</p>\n", | ||
"<p>\n", | ||
" If you're reading this message in another frontend (for example, a static\n", | ||
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n", | ||
" it may mean that your frontend doesn't currently support widgets.\n", | ||
"</p>\n" | ||
], | ||
"text/plain": [ | ||
"Figure(layout=FigureLayout(height='420px'))" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"# Plot Heatmap\n", | ||
"fig = gmaps.figure()\n", | ||
"\n", | ||
"# Create heat layer\n", | ||
"heat_layer = gmaps.heatmap_layer(locations,weights=ratings)\n", | ||
"\n", | ||
"\n", | ||
"# Add layer\n", | ||
"fig.add_layer(heat_layer)\n", | ||
"\n", | ||
"# Display figure\n", | ||
"fig" | ||
] | ||
}, | ||
{ | ||
"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.6.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |