{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2\n", "import models\n", "import orca\n", "from urbansim.maps import dframe_explorer" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Filling column non_residential_rent with value 0 (142400 values)\n", "Filling column residential_units with value 0 (0 values)\n", "Filling column year_built with value 1927.0 (3116 values)\n", "Filling column residential_sales_price with value 0 (14196 values)\n", "Filling column non_residential_sqft with value 0 (1341 values)\n", "Filling column building_type_id with value 2.0 (0 values)\n", "Filling column job_category with value service (331 values)\n" ] } ], "source": [ "d = {tbl: orca.get_table(tbl).to_frame() for tbl in ['buildings', 'jobs', 'households', 'zones', 'zones_prices']}" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Bottle v0.12.7 server starting up (using WSGIRefServer())...\n", "Listening on http://localhost:8765/\n", "Hit Ctrl-C to quit.\n", "\n", "127.0.0.1 - - [14/Aug/2014 17:11:55] \"GET / HTTP/1.1\" 200 28075\n", "127.0.0.1 - - [14/Aug/2014 17:11:55] \"GET /data/zones.json HTTP/1.1\" 200 7389418\n", "127.0.0.1 - - [14/Aug/2014 17:11:57] \"GET /favicon.ico HTTP/1.1\" 404 742\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "df.groupby('zone_id')['income'].mean()\n", "df.groupby('zone_id')['income'].quantile(.5)" ] }, { "name": "stderr", "output_type": "stream", "text": [ "127.0.0.1 - - [14/Aug/2014 17:12:08] \"GET /map_query/households/empty/zone_id/income/mean() HTTP/1.1\" 200 4803\n", "127.0.0.1 - - [14/Aug/2014 17:12:23] \"GET /map_query/households/empty/zone_id/income/quantile(.5) HTTP/1.1\" 200 2920\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "df.groupby('zone_id')['income'].quantile(.75)\n", "df.query('income > 30000').groupby('zone_id')['income'].quantile(.75)" ] }, { "name": "stderr", "output_type": "stream", "text": [ "127.0.0.1 - - [14/Aug/2014 17:12:27] \"GET /map_query/households/empty/zone_id/income/quantile(.75) HTTP/1.1\" 200 3031\n", "/Users/ffoti/anaconda/lib/python2.7/site-packages/pandas/computation/ops.py:62: DeprecationWarning: object() takes no parameters\n", " return supr_new(klass, name, env, side=side, encoding=encoding)\n" ] } ], "source": [ "dframe_explorer.start(d, \n", " center=[37.7792, -122.2191],\n", " zoom=11,\n", " shape_json='data/zones.json',\n", " geom_name='ZONE_ID', # from JSON file\n", " join_name='zone_id', # from data frames\n", " precision=2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Click here to navigate maps](http://localhost:8765/)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.9" } }, "nbformat": 4, "nbformat_minor": 0 }