{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Searching for Pronto's Power-Users\n", "\n", "This is a work-in-progress, analyzing the open data from [Pronto Cycle Share's Data Challenge](http://www.prontocycleshare.com/datachallenge).\n", "\n", "See [ProntoData.ipynb](ProntoData.ipynb) for an intro to the data; this notebook uses pieces that were derived there." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import numpy as np\n", "import seaborn as sns; sns.set()" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "trips = pd.read_csv('2015_trip_data.csv',\n", " parse_dates=['starttime', 'stoptime'],\n", " infer_datetime_format=True)\n", "t_start = pd.DatetimeIndex(trips['starttime'])\n", "t_stop = pd.DatetimeIndex(trips['stoptime'])\n", "trips['date'] = t_start.date.astype('datetime64')\n", "trips['starttime'] = t_start.time\n", "trips['stoptime'] = t_stop.time\n", "trips['minuteofday'] = t_start.hour * 60 + t_start.minute\n", "trips['minutes'] = trips.tripduration / 60." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "stations = pd.read_csv('2015_station_data.csv')\n", "pronto_shop = dict(id=54, name=\"Pronto shop\",\n", " terminal=\"Pronto shop\",\n", " lat=47.6173156, long=-122.3414776,\n", " dockcount=100, online='10/13/2014')\n", "stations = stations.append(pronto_shop, ignore_index=True)\n", "distances = pd.read_csv('station_distances.csv', index_col='terminal')\n", "distances /= 1609.34 # convert meters to miles" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [], "source": [ "trips['distance'] = [distances.loc[ind] for ind in\n", " zip(trips.from_station_id, trips.to_station_id)]\n", "trips['speed'] = trips.distance * 60 / trips.minutes" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", " | trip_id | \n", "starttime | \n", "stoptime | \n", "bikeid | \n", "tripduration | \n", "from_station_name | \n", "to_station_name | \n", "from_station_id | \n", "to_station_id | \n", "usertype | \n", "gender | \n", "birthyear | \n", "date | \n", "minuteofday | \n", "minutes | \n", "distance | \n", "speed | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "431 | \n", "10:31:00 | \n", "10:48:00 | \n", "SEA00298 | \n", "985.935 | \n", "2nd Ave & Spring St | \n", "Occidental Park / Occidental Ave S & S Washing... | \n", "CBD-06 | \n", "PS-04 | \n", "Annual Member | \n", "Male | \n", "1960 | \n", "2014-10-13 | \n", "631 | \n", "16.432250 | \n", "0.455466 | \n", "1.663069 | \n", "
1 | \n", "432 | \n", "10:32:00 | \n", "10:48:00 | \n", "SEA00195 | \n", "926.375 | \n", "2nd Ave & Spring St | \n", "Occidental Park / Occidental Ave S & S Washing... | \n", "CBD-06 | \n", "PS-04 | \n", "Annual Member | \n", "Male | \n", "1970 | \n", "2014-10-13 | \n", "632 | \n", "15.439583 | \n", "0.455466 | \n", "1.769994 | \n", "
2 | \n", "433 | \n", "10:33:00 | \n", "10:48:00 | \n", "SEA00486 | \n", "883.831 | \n", "2nd Ave & Spring St | \n", "Occidental Park / Occidental Ave S & S Washing... | \n", "CBD-06 | \n", "PS-04 | \n", "Annual Member | \n", "Female | \n", "1988 | \n", "2014-10-13 | \n", "633 | \n", "14.730517 | \n", "0.455466 | \n", "1.855194 | \n", "
3 | \n", "434 | \n", "10:34:00 | \n", "10:48:00 | \n", "SEA00333 | \n", "865.937 | \n", "2nd Ave & Spring St | \n", "Occidental Park / Occidental Ave S & S Washing... | \n", "CBD-06 | \n", "PS-04 | \n", "Annual Member | \n", "Female | \n", "1977 | \n", "2014-10-13 | \n", "634 | \n", "14.432283 | \n", "0.455466 | \n", "1.893531 | \n", "
4 | \n", "435 | \n", "10:34:00 | \n", "10:49:00 | \n", "SEA00202 | \n", "923.923 | \n", "2nd Ave & Spring St | \n", "Occidental Park / Occidental Ave S & S Washing... | \n", "CBD-06 | \n", "PS-04 | \n", "Annual Member | \n", "Male | \n", "1971 | \n", "2014-10-13 | \n", "634 | \n", "15.398717 | \n", "0.455466 | \n", "1.774692 | \n", "