Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weekend homwork - Daniel #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
1,978 changes: 1,978 additions & 0 deletions ATUS ANALYSIS.ipynb

Large diffs are not rendered by default.

160 changes: 160 additions & 0 deletions Blank_US_Map.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Starting Point.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
},
{
"cell_type": "code",
"collapsed": false,
"collapsed": true,
"input": [
"adults_crit = (summary.TEAGE >= 18)\n",
"no_children_crit = (summary.TRCHILDNUM == 0)"
Expand Down
Binary file added US_FIPS_Codes.xls
Binary file not shown.
180 changes: 180 additions & 0 deletions Untitled0.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
{
"metadata": {
"name": "",
"signature": "sha256:7c8fb25bb143d7dda2f352f429f6e7c57dc3600f9a3b4b03303e6fbacea2de0c"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"import pandas as pd\n",
"import vincent\n",
"vincent.core.initialize_notebook()\n",
"\n",
"state_data = pd.read_csv(state_unemployment)\n",
"vis.tabular_data(state_data, columns=['State', 'Unemployment'])\n",
"vis.geo_data(bind_data='data.id', reset=True, states=state_geo)\n",
"vis.update_map(scale=1000, projection='albersUsa')\n",
"vis + (['#c9cedb', '#0b0d11'], 'scales', 0, 'range')\n",
"vis.to_json(path)\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"\n",
" <script>\n",
" \n",
" function vct_load_lib(url, callback){\n",
" if(typeof d3 !== 'undefined' &&\n",
" url === 'http://d3js.org/d3.v3.min.js'){\n",
" callback()\n",
" }\n",
" var s = document.createElement('script');\n",
" s.src = url;\n",
" s.async = true;\n",
" s.onreadystatechange = s.onload = callback;\n",
" s.onerror = function(){\n",
" console.warn(\"failed to load library \" + url);\n",
" };\n",
" document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
" };\n",
" var vincent_event = new CustomEvent(\n",
" \"vincent_libs_loaded\",\n",
" {bubbles: true, cancelable: true}\n",
" );\n",
" \n",
" function load_all_libs(){\n",
" console.log('Loading Vincent libs...')\n",
" vct_load_lib('http://d3js.org/d3.v3.min.js', function(){\n",
" vct_load_lib('http://d3js.org/d3.geo.projection.v0.min.js', function(){\n",
" vct_load_lib('http://wrobstory.github.io/d3-cloud/d3.layout.cloud.js', function(){\n",
" vct_load_lib('http://wrobstory.github.io/vega/vega.v1.3.3.js', function(){\n",
" window.dispatchEvent(vincent_event);\n",
" });\n",
" });\n",
" });\n",
" });\n",
" };\n",
" if(typeof define === \"function\" && define.amd){\n",
" if (window['d3'] === undefined ||\n",
" window['topojson'] === undefined){\n",
" require.config(\n",
" {paths: {\n",
" d3: 'http://d3js.org/d3.v3.min',\n",
" topojson: 'http://d3js.org/topojson.v1.min'\n",
" }\n",
" }\n",
" );\n",
" require([\"d3\"], function(d3){\n",
" console.log('Loading Vincent from require.js...')\n",
" window.d3 = d3;\n",
" require([\"topojson\"], function(topojson){\n",
" window.topojson = topojson;\n",
" load_all_libs();\n",
" });\n",
" });\n",
" } else {\n",
" load_all_libs();\n",
" };\n",
" }else{\n",
" console.log('Require.js not found, loading manually...')\n",
" load_all_libs();\n",
" };\n",
"\n",
" </script>"
],
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x10aded748>"
]
}
],
"prompt_number": 28
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"display(vis)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div id=\"visa917e9e3c9274843b92f7e2827754a3d\"></div>\n",
"<script>\n",
" ( function() {\n",
" var _do_plot = function() {\n",
" if (typeof vg === 'undefined') {\n",
" window.addEventListener('vincent_libs_loaded', _do_plot)\n",
" return;\n",
" }\n",
" vg.parse.spec({\"axes\": [], \"data\": [{\"format\": {\"feature\": \"world-countries\", \"type\": \"topojson\"}, \"name\": \"countries\", \"transform\": [{\"projection\": \"winkel3\", \"scale\": 200, \"translate\": [480.0, 250.0], \"type\": \"geopath\", \"value\": \"data\"}], \"url\": \"world-countries.topo.json\"}], \"height\": 500, \"legends\": [], \"marks\": [{\"from\": {\"data\": \"countries\"}, \"properties\": {\"enter\": {\"path\": {\"field\": \"path\"}, \"stroke\": {\"value\": \"#000000\"}}, \"update\": {\"fill\": {\"value\": \"steelblue\"}}}, \"type\": \"path\"}], \"padding\": \"auto\", \"scales\": [], \"width\": 960}, function(chart) {\n",
" chart({el: \"#visa917e9e3c9274843b92f7e2827754a3d\"}).update();\n",
" });\n",
" };\n",
" _do_plot();\n",
" })();\n",
"</script>\n",
"<style>.vega canvas {width: 100%;}</style>\n",
" "
],
"metadata": {},
"output_type": "display_data",
"text": [
"<vincent.charts.Map at 0x10aded6a0>"
]
}
],
"prompt_number": 29
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"state_data = pd.read_csv(state_unemployment)\n",
"vis.tabular_data(state_data, columns=['State', 'Unemployment'])\n",
"vis.geo_data(bind_data='data.id', reset=True, states=state_geo)\n",
"vis.update_map(scale=1000, projection='albersUsa')\n",
"vis + (['#c9cedb', '#0b0d11'], 'scales', 0, 'range')\n",
"vis.to_json(path)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'state_unemployment' is not defined",
"output_type": "pyerr",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-31-1b82c73f7070>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mstate_data\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread_csv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstate_unemployment\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mvis\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtabular_data\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstate_data\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcolumns\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'State'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Unemployment'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mvis\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgeo_data\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbind_data\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'data.id'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mreset\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstates\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mstate_geo\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mvis\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mupdate_map\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mscale\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1000\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mprojection\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'albersUsa'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mvis\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'#c9cedb'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'#0b0d11'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'scales'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'range'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'state_unemployment' is not defined"
]
}
],
"prompt_number": 31
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
Loading