Skip to content

Instantly share code, notes, and snippets.

@eddieberklee
Created May 7, 2013 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eddieberklee/5536678 to your computer and use it in GitHub Desktop.
Save eddieberklee/5536678 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "forms_javascript"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Stock Performance of Product Releases"
]
},
{
"cell_type": "heading",
"level": 5,
"metadata": {},
"source": [
"Eugene Kim and Eddie Lee"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Problem"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\"Large stock moves are almost always driven by a compelling new product or service, or by new management that brings new ideas, or by new industry conditions that affect an entire industry group in a positive way.\"\n",
"- MarketSmith.com"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Objective"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Using Apple as our subject, we wish to examine how a company's stock performances are affected by certain products. Ultimately, we want to open up and provide easily-accessible insights and analysis. We would like for the success of a product to be more presentable than just numbers."
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Implementation Details"
]
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Dependencies"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"urllib,urllib2 - scraping html content from URLs\n",
"re - regular expressions matching\n",
"bs4 - beautifulsoup for clean scraping of html"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%gui wx\n",
"import urllib, urllib2\n",
"import re\n",
"import datetime\n",
"import calendar\n",
"from bs4 import BeautifulSoup\n",
"import random\n",
"\n",
"import pylab as pl\n",
"from pylab import get_current_fig_manager as gcfm\n",
"import wx\n",
"import numpy as np"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Date Class"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Used for standardizing and making more convenient the way that we deal with dates from various sources such as Yahoo Finance and a datetime object."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"class Date:\n",
" def __init__(self, date):\n",
" months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\n",
" if re.search('[a-zA-Z]{3}\\ [0-9]{1,2},\\ [0-9]{4}',date):\n",
" splitDate = date.split(' ')\n",
"\n",
" threeLetterMonths = map(lambda month: month[:3], months)\n",
"\n",
" self.m = int(threeLetterMonths.index(splitDate[0])+1)\n",
"\n",
" if ',' in splitDate[1]:\n",
" self.d = int(splitDate[1].replace(',',''))\n",
" self.y = int(splitDate[2])\n",
" self.date = `self.m` + '-' + `self.d` + '-' + `self.y`\n",
" else:\n",
" splitDate = date.split('-')\n",
" self.date = date\n",
" self.m = int(splitDate[0])\n",
" self.d = int(splitDate[1])\n",
" self.y = int(splitDate[2])\n",
"\n",
" def __repr__(self):\n",
" # return str('Date(' + self.date + ')')\n",
" return str(self.date)\n",
"\n",
" # returns (start date, end date)\n",
" def dateRange(self, daysPadding): # daysPadding is in days\n",
" import datetime\n",
"\n",
" if self.d == 0: # handle the case the day is 0 (day wasn't indicated on wikipedia page)\n",
" self.d = 1\n",
" date = datetime.date(int(self.y), int(self.m), int(self.d))\n",
" \n",
" difference = datetime.timedelta(days=daysPadding)\n",
" beginInterval = date - difference\n",
" endInterval = date + difference\n",
" earliestDate = datetime.date(1985, 9, 2)\n",
"\n",
" # earliest borderline check\n",
" if beginInterval < earliestDate: \n",
" beginInterval = earliestDate\n",
" endInterval = beginInterval + difference + difference\n",
" \n",
" beginDate = Date(str(beginInterval.month) + '-' + str(beginInterval.day) + '-' + str(beginInterval.year))\n",
" endDate = Date(str(endInterval.month) + '-' + str(endInterval.day) + '-' + str(endInterval.year))\n",
" #make sure none of dates returned are weekends\n",
" import calendar\n",
" if calendar.weekday(beginDate.y, beginDate.m, beginDate.d) == 6: # beginDate is Sunday\n",
" # print 'beginDate is Sunday'\n",
" difference = datetime.timedelta(days=2)\n",
" date = datetime.date(int(beginDate.y), int(beginDate.m), int(beginDate.d))\n",
" beginInterval = date - difference\n",
" elif calendar.weekday(beginDate.y, beginDate.m, beginDate.d) == 5: # beginDate is Saturday\n",
" # print 'beginDate is Saturday'\n",
" difference = datetime.timedelta(days=1)\n",
" date = datetime.date(int(beginDate.y), int(beginDate.m), int(beginDate.d))\n",
" beginInterval = date - difference\n",
" if calendar.weekday(endDate.y, endDate.m, endDate.d) == 6: # endDate is Sunday\n",
" # print 'endDate is Sunday'\n",
" difference = datetime.timedelta(days=1)\n",
" date = datetime.date(int(endDate.y), int(endDate.m), int(endDate.d))\n",
" endInterval = date + difference\n",
" elif calendar.weekday(endDate.y, endDate.m, endDate.d) == 5: # endDate is Saturday\n",
" # print 'endDate is Saturday'\n",
" difference = datetime.timedelta(days=2)\n",
" date = datetime.date(int(endDate.y), int(endDate.m), int(endDate.d))\n",
" endInterval = date + difference\n",
"\n",
" # begin interval is a weekend:\n",
" beginDate = Date(str(beginInterval.month) + '-' + str(beginInterval.day) + '-' + str(beginInterval.year))\n",
" endDate = Date(str(endInterval.month) + '-' + str(endInterval.day) + '-' + str(endInterval.year))\n",
" # print self\n",
" # print beginDate\n",
" # print endDate\n",
" return (beginDate, endDate)\n",
"\n",
" #returns an integer representation of the date that makes the date easy to sort\n",
" def numericDate(self):\n",
" year = str(self.y)\n",
" month = str(self.m)\n",
" day = str(self.d)\n",
"\n",
" if len(year) == 1: year = '0'+ year\n",
" if len(month) == 1: month = '0'+ month\n",
" if len(day) == 1: day = '0'+ day\n",
"\n",
" return int(year + month + day)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Web Scraping"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Scrape and parse the Wikipedia page for Apple products from 'Timeline of Apple Inc. Products'"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def parse_yahoo_stock(line):\n",
" parts = line.split(',')\n",
" parts_dict = {}\n",
" # for product releases there may be a difference between diff('high', 'close')\n",
" # as opposed to more steady differences for a 'normal' non-release day\n",
" legends = ['Date', 'Open', 'High', 'Low', 'Close', 'Volume', 'Adj Close']\n",
" floats = [0, 1, 1, 1, 1, 0, 1]\n",
" for i in range(len(parts)):\n",
" if i == 5:\n",
" parts_dict[legends[i]] = int(parts[i])\n",
" if floats[i]:\n",
" parts_dict[legends[i]] = float(parts[i])\n",
" else:\n",
" parts_dict[legends[i]] = parts[i]\n",
" return parts_dict\n",
"\n",
"def getProductReleasesForApple():\n",
" import urllib, urllib2\n",
" from bs4 import BeautifulSoup\n",
" import re\n",
" article = \"Timeline of Apple Inc. products\"\n",
" article = urllib.quote(article) # sanitize\n",
"\n",
" opener = urllib2.build_opener()\n",
" opener.addheaders = [('User-agent', 'Mozilla/5.0')] # wikipedia blocks obvious bot attempts\n",
" \n",
" resource = opener.open(\"http://en.wikipedia.org/wiki/\"+article)\n",
" data = resource.read()\n",
" resource.close()\n",
" \n",
" soup = BeautifulSoup(data)\n",
"\n",
" # print soup.find('div',id=\"bodyContent\")\n",
"\n",
"\n",
" bodyContent = soup.find('div',id=\"bodyContent\")\n",
" wikitables = bodyContent.find_all('table',class_=\"wikitable\")\n",
"\n",
" products = {}\n",
"\n",
" for wikitable in wikitables:\n",
" m = re.search('<b>[0-9]+</b>', str(wikitable))\n",
" year = m.group(0)\n",
" # if first == 0:\n",
" # first = 1\n",
" first = 1\n",
" trs = wikitable.find_all('tr')\n",
" year = ''\n",
" date = ''\n",
" productName = ''\n",
" family = ''\n",
" deathDate = ''\n",
" rowspan = 0\n",
" rowspanFix = 1\n",
" spanSub = 0\n",
" for tr in trs:\n",
" tr = BeautifulSoup(str(tr))\n",
" if len(tr.find_all('td')) != 0:\n",
" tds = tr.find_all('td')\n",
" count = 0\n",
" # if len(tds.find_all('b')) != 0:\n",
" if first == 1:\n",
" for td in tds:\n",
" if count == 0:\n",
" m = re.search('<b>[0-9]+</b>', str(td))\n",
" year = m.group(0)\n",
" year = year[3:-4]\n",
" elif count == 1:\n",
" # m = re.search('>[a-zA-Z0-9\\ ]+<', str(td))\n",
" # date = m.group(0)\n",
" date = td.text\n",
" date = date + ' ' + year\n",
" elif count == 2:\n",
" productName = td.text\n",
" elif count == 3:\n",
" family = td.text\n",
" elif count == 4:\n",
" deathDate = td.text\n",
" count += 1\n",
" first = 0\n",
" months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\n",
" dateSplit = str(date).split(' ')\n",
" if ',' in dateSplit[1]: dateSplit[1] = dateSplit[1][:-1]\n",
" if len(dateSplit) == 3:\n",
" newD = str(months.index(dateSplit[0])+1)+'-'+dateSplit[1]+'-'+dateSplit[2]\n",
" else:\n",
" newD = str(months.index(dateSplit[0])+1)+'-'+'00'+'-'+dateSplit[1]\n",
" products[productName] = [Date(newD), family, deathDate]\n",
" else:\n",
" if len(tds) == 3:\n",
" for td in tds:\n",
" if count == 0:\n",
" productName = td.text\n",
" if count == 1:\n",
" family = td.text\n",
" if count == 2:\n",
" deathDate = td.text\n",
" count += 1\n",
" months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\n",
" dateSplit = str(date).split(' ')\n",
" if ',' in dateSplit[1]: dateSplit[1] = dateSplit[1][:-1]\n",
" if len(dateSplit) == 3:\n",
" newD = str(months.index(dateSplit[0])+1)+'-'+dateSplit[1]+'-'+dateSplit[2]\n",
" else:\n",
" newD = str(months.index(dateSplit[0])+1)+'-'+'00'+'-'+dateSplit[1]\n",
" products[str(productName)] = [Date(newD), str(family), str(deathDate)]\n",
" elif len(tds) == 4:\n",
" for td in tds:\n",
" if count == 0:\n",
" date = td.text\n",
" date = date + ' ' + year\n",
" if count == 1:\n",
" productName = td.text\n",
" if count == 2:\n",
" family = td.text\n",
" if count == 3:\n",
" deathDate = td.text\n",
" count += 1\n",
" months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\n",
" dateSplit = str(date).split(' ')\n",
" if ',' in dateSplit[1]: dateSplit[1] = dateSplit[1][:-1]\n",
" if len(dateSplit) == 3:\n",
" newD = str(months.index(dateSplit[0])+1)+'-'+dateSplit[1]+'-'+dateSplit[2]\n",
" else:\n",
" newD = str(months.index(dateSplit[0])+1)+'-'+'00'+'-'+dateSplit[1]\n",
" products[str(productName)] = [Date(newD), str(family), str(deathDate)]\n",
" elif len(tr.find_all('th')) != 0:\n",
" ths = tr.find_all('th')\n",
" return products\n",
"\n",
"getProductReleasesForApple()"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "pyout",
"prompt_number": 3,
"text": [
"{'AirPort (802.11b, \"Graphite\")': [7-21-1999, 'AirPort', 'November 13, 2001'],\n",
" 'AirPort Express (802.11g)': [6-7-2004, 'AirPort Express', 'March 17, 2008'],\n",
" 'AirPort Express 802.11n (1st gen)': [3-17-2008,\n",
" 'AirPort Express',\n",
" 'June 11, 2012'],\n",
" 'AirPort Express 802.11n (2nd gen)': [6-11-2012,\n",
" 'AirPort Express',\n",
" 'current'],\n",
" 'AirPort Extreme 802.11n (3rd gen)': [3-3-2009,\n",
" 'AirPort',\n",
" 'October 20, 2009'],\n",
" 'AirPort Extreme 802.11n (4th gen)': [10-20-2009, 'AirPort', 'June 21, 2011'],\n",
" 'AirPort Extreme 802.11n (5th gen)': [6-21-2011, 'AirPort', 'current'],\n",
" 'AirPort Utility': [10-12-2011, 'Software', 'current'],\n",
" 'Aperture 2': [2-12-2008, 'Software', 'February 9, 2010'],\n",
" u'Aperture 3': [2-9-2010, u'Software', u'current'],\n",
" 'Apple 3.5\" Drive': [9-1-1986, 'Drives', ''],\n",
" 'Apple 5.25\" Drive': [9-1-1986, 'Drives', ''],\n",
" 'Apple Color Plotter': [6-00-1984, 'Printers', ''],\n",
" 'Apple ColorMonitor IIc': [9-1-1985, 'Displays', ''],\n",
" 'Apple ColorMonitor IIe': [9-1-1985, 'Displays', ''],\n",
" 'Apple Design Powered Speakers': [3-22-1993, 'PowerCD', 'January 1, 1995'],\n",
" u'Apple Dot Matrix Printer': [10-1-1982, u'Printers', u'December 1, 1983'],\n",
" 'Apple DuoDisk 5.25': [5-1-1984, 'Drives', ''],\n",
" 'Apple EarPods': [9-12-2012, 'iPod Accessories', 'current'],\n",
" 'Apple FDHD SuperDrive': [8-1-1989, 'Drives', ''],\n",
" 'Apple Hard Disk 20SC': [9-1-1986, 'Drives', ''],\n",
" 'Apple Hi-Resolution Monochrome Display': [3-7-1989, 'Displays', ''],\n",
" u'Apple I': [7-1-1976, u'Apple I', u'September 1, 1977'],\n",
" u'Apple II': [4-1-1977, u'Apple II', u'June 1, 1979'],\n",
" 'Apple II EuroPlus': [6-1-1979, 'Apple II', 'December 1, 1982'],\n",
" 'Apple II J-Plus': [6-1-1979, 'Apple II', 'December 1, 1982'],\n",
" u'Apple II Plus': [6-1-1979, u'Apple II', u'December 1, 1982'],\n",
" 'Apple IIGS': [9-1-1986, 'Apple II', 'December 1, 1992'],\n",
" 'Apple IIGS (1 MB, ROM 3)[3]': [10-1-1989, 'Apple II', 'December 1, 1992'],\n",
" u'Apple III': [9-1-1980, u'Apple III', u'December 1, 1981'],\n",
" 'Apple III Plus': [12-1-1983, 'Apple III', 'April 1, 1984'],\n",
" 'Apple III Revised[1]': [12-1-1981, 'Apple III', 'December 1, 1983'],\n",
" 'Apple IIc': [4-1-1984, 'Apple II', 'September 1, 1986'],\n",
" 'Apple IIc Memory Expansion': [9-1-1986, 'Apple II', 'September 1, 1988'],\n",
" 'Apple IIc Plus': [9-1-1988, 'Apple II', 'September 1, 1990'],\n",
" u'Apple IIe': [1-1-1983, u'Apple II', u'March 1, 1985'],\n",
" 'Apple IIe Card (requires Macintosh LC)': [3-1-1991,\n",
" 'Apple II',\n",
" 'May 1, 1995'],\n",
" 'Apple IIe Enhanced': [3-1-1985, 'Apple II', 'January 1, 1987'],\n",
" 'Apple IIe Platinum': [1-1-1987, 'Apple II', 'November 1, 1993'],\n",
" 'Apple ImageWriter': [12-1-1983, 'Printers', 'December 1, 1985'],\n",
" 'Apple ImageWriter II': [4-1-1985, 'Printers', '1996'],\n",
" 'Apple ImageWriter Wide Carriage': [6-00-1984, 'Printers', ''],\n",
" 'Apple Keyboard (short)': [3-3-2009, 'Apple Keyboard', 'October 20, 2009'],\n",
" 'Apple Keyboard with Numeric Keypad': [8-7-2007, 'Apple Keyboard', 'current'],\n",
" 'Apple LaserWriter': [1-1-1985, 'Printers', 'December 1, 1985'],\n",
" u'Apple LaserWriter Family': [1-1-1988, u'Printers', u''],\n",
" 'Apple LaserWriter Plus': [1-16-1986, 'Printers', ''],\n",
" 'Apple Letter Quality Printer': [10-1-1982, 'Printers', 'December 1, 1983'],\n",
" u'Apple Lisa 2': [1-1-1984, u'68000', u'January 1, 1985'],\n",
" 'Apple Lisa[2]': [1-1-1983, '68000', 'January 1, 1984'],\n",
" 'Apple LocalTalk Connector': [1-1-1985, 'Networking', ''],\n",
" 'Apple Macintosh Portrait Display': [3-7-1989, 'Displays', ''],\n",
" 'Apple Mighty Mouse (revised)': [8-7-2007, 'Apple Mouse', 'current'],\n",
" 'Apple Modem 1200': [1-24-1984, 'Modems', ''],\n",
" 'Apple Modem 2400': [7-00-1989, 'Modems', 'December 1992'],\n",
" 'Apple Modem 300': [1-24-1984, 'Modems', ''],\n",
" 'Apple Monochrome Monitor': [9-1-1986, 'Displays', ''],\n",
" 'Apple Mouse IIc': [4-1-1984, 'Apple Mouse', 'December 1, 1985'],\n",
" u'Apple Network Server 500': [2-15-1996, u'Network Server', u'April 1, 1997'],\n",
" 'Apple Network Server 700/150': [2-15-1996,\n",
" 'Network Server',\n",
" 'April 1, 1997'],\n",
" 'Apple Network Server 700/200': [10-16-1996,\n",
" 'Network Server',\n",
" 'April 1, 1997'],\n",
" 'Apple PC 5.25\" Drive': [8-00-1987, 'Drives', ''],\n",
" 'Apple Personal Modem': [4-1-1985, 'Modems', ''],\n",
" u'Apple ProFile': [9-1-1981, u'Drives', u''],\n",
" 'Apple QuickTake 100': [2-2-1994, 'QuickTake', 'January 1, 1995'],\n",
" 'Apple Remote Desktop 3': [4-11-2006, 'Software', 'current'],\n",
" 'Apple Scanner': [8-00-1988, 'Scanner', ''],\n",
" 'Apple Scribe Printer': [4-1-1984, 'Printers', 'December 1, 1985'],\n",
" 'Apple SilenType': [6-1-1979, 'Printers', 'October 1, 1982'],\n",
" u'Apple TV (1st gen)': [3-21-2007, u'Apple TV', u'September 1, 2010'],\n",
" 'Apple TV (2nd gen)': [9-1-2010, 'Apple TV', 'March 7, 2012'],\n",
" 'Apple TV (3rd gen)': [3-16-2012, 'Apple TV', 'current'],\n",
" 'Apple Tape Backup 40SC': [8-00-1987, 'Drives', ''],\n",
" 'Apple Two Page Monochrome Monitor': [3-7-1989, 'Displays', ''],\n",
" 'Apple UniDisk 3.5': [9-1-1985, 'Drives', 'January 1, 1987'],\n",
" 'Apple UniDisk 5.25': [6-00-1985, 'Drives', 'September 1, 1986'],\n",
" 'Apple Wireless Keyboard (Aluminum)': [8-7-2007, 'Apple Keyboard', 'current'],\n",
" 'Apple Writer 1.0': [6-1-1979, 'Software', 'January 1, 1992'],\n",
" 'AppleCD SC': [3-00-1988, 'Drives', ''],\n",
" 'AppleColor 100': [12-00-1984, 'Displays', ''],\n",
" 'AppleColor Composite Monitor': [9-1-1986, 'Displays', ''],\n",
" 'AppleColor Hi-Resolution RGB Monitor': [3-2-1987,\n",
" 'Displays',\n",
" 'December 1992'],\n",
" 'AppleColor RGB Monitor': [9-1-1986, 'Displays', ''],\n",
" 'AppleFax Modem': [8-00-1987, 'Modems', ''],\n",
" 'AppleShare Server 1.0': [1-1-1987, 'Software', ''],\n",
" 'Bell & Howell': [6-1-1979, 'Apple II', 'December 1, 1982'],\n",
" 'Bell & Howell Disk II': [6-1-1979, 'Drives', 'December 1, 1982'],\n",
" 'Bento 2.0': [10-14-2008, 'Software', 'September 29, 2009'],\n",
" 'Cards': [10-12-2011, 'Software', 'current'],\n",
" 'Centris / Quadra 660AV': [7-29-1993,\n",
" 'Centris / Quadra',\n",
" 'September 12, 1994'],\n",
" 'Centris 610': [2-10-1993, 'Centris', 'October 21, 1993'],\n",
" 'Centris 650': [2-10-1993, 'Centris', 'October 21, 1993'],\n",
" 'Cinema Display (20\")': [6-28-2004, 'Displays', 'February 2009'],\n",
" 'Cinema Display (22\")': [7-19-2000, 'Displays', 'January 28, 2003'],\n",
" 'Cinema Display (23\")': [6-28-2004, 'Displays', 'November 2008'],\n",
" 'Cinema Display (30\")': [6-28-2004, 'Displays', 'July 27, 2010'],\n",
" u'Disk II': [6-1-1978, u'Drives', u'May 1, 1984'],\n",
" 'Disk III': [9-1-1980, 'Drives', 'May 1, 1984'],\n",
" 'Disk IIc': [4-1-1984, 'Drives', ''],\n",
" 'FileMaker Pro 10': [1-6-2009, 'Software', 'March 9, 2010'],\n",
" 'Final Cut Express 4': [11-15-2007, 'Software', 'July 23, 2009'],\n",
" 'Final Cut Server': [9-18-2008, 'Software', 'July 23, 2009'],\n",
" 'Final Cut Server 1.5': [7-23-2009, 'Software', 'June 21, 2011'],\n",
" 'Final Cut Studio 2': [4-17-2008, 'Software', 'July 23, 2009'],\n",
" 'Final Cut Studio 3': [7-23-2009, 'Software', 'current'],\n",
" 'Find My Friends': [10-12-2011, 'Software', 'current'],\n",
" 'ImageWriter LQ': [8-00-1987, 'Printers', 'December 1990'],\n",
" 'In-Ear Headphones': [9-9-2008, 'iPod Accessories', 'current'],\n",
" 'LED Cinema Display': [10-14-2008, 'Displays', 'current'],\n",
" 'Logic Express 8': [5-29-2008, 'Software', 'July 23, 2009'],\n",
" 'Logic Express 9': [7-23-2009, 'Software', 'December 13, 2011'],\n",
" 'Logic Studio': [9-12-2007, 'Software', 'July 23, 2009'],\n",
" 'Logic Studio 2': [7-23-2009, 'Software', 'current'],\n",
" u'Mac Mini': [1-11-2005, u'Mac Mini', u'February 28, 2006'],\n",
" 'Mac Mini (Early 2009)': [3-3-2009, 'Mac Mini', 'October 20, 2009'],\n",
" 'Mac Mini (Late 2009)': [10-20-2009, 'Mac Mini', ''],\n",
" 'Mac Mini (Late 2012)': [10-23-2012, 'Mac Mini', 'current'],\n",
" 'Mac Mini (Mid 2007)': [8-7-2007, 'Mac Mini', 'March 3, 2009'],\n",
" 'Mac Mini (Mid 2010)': [6-15-2010, 'Mac Mini', 'July 20, 2011'],\n",
" 'Mac Mini (Mid 2011)': [7-20-2011, 'Mac Mini', 'October 23, 2012'],\n",
" 'Mac Mini Core Duo': [2-28-2006, 'Mac Mini', 'August 7, 2007'],\n",
" 'Mac Mini Core Solo': [2-28-2006, 'Mac Mini', 'September 6, 2006'],\n",
" 'Mac OS X Leopard (10.5)': [10-27-2007, 'Software', 'August 28, 2009'],\n",
" 'Mac OS X Lion (10.7)': [7-20-2011, 'Software', 'July 25, 2012'],\n",
" 'Mac OS X Server (10.5)': [10-27-2007, 'Software', 'August 28, 2009'],\n",
" 'Mac OS X Server (10.6)': [8-28-2009, 'Software', 'July 20, 2011'],\n",
" 'Mac OS X Snow Leopard (10.6)': [8-28-2009, 'Software', 'July 20, 2011'],\n",
" 'Mac Pro': [8-7-2006, 'Mac Pro', 'January 8, 2008'],\n",
" 'Mac Pro (Early 2008)': [1-8-2008, 'Mac Pro', 'March 3, 2009'],\n",
" 'Mac Pro (Early 2009)': [3-3-2009, 'Mac Pro', 'August 9, 2010'],\n",
" 'Mac Pro (Mid 2010)': [8-9-2010, 'Mac Pro', 'June 11, 2012'],\n",
" 'Mac Pro (Mid 2012)': [6-11-2012, 'Mac Pro', 'current'],\n",
" 'MacBook': [5-16-2006, 'MacBook', 'February 26, 2008'],\n",
" 'MacBook (Early 2008)': [2-26-2008, 'MacBook', 'October 14, 2008'],\n",
" 'MacBook (Early 2009) (White)': [1-29-2009, 'MacBook', 'May 27, 2009'],\n",
" 'MacBook (Late 2008) (Aluminum)': [10-14-2008, 'MacBook', 'June 8, 2009'],\n",
" 'MacBook (Late 2008) (White)': [10-14-2008, 'MacBook', 'January 29, 2009'],\n",
" 'MacBook (Late 2009)': [10-20-2009, 'MacBook', 'May 18, 2010'],\n",
" 'MacBook (Mid 2009)': [5-27-2009, 'MacBook', 'October 20, 2009'],\n",
" 'MacBook (Mid 2010)': [5-18-2010, 'MacBook', 'July 20, 2011'],\n",
" 'MacBook Air (Early 2008)': [1-15-2008, 'MacBook Air', 'October 14, 2008'],\n",
" 'MacBook Air (Late 2008)': [10-14-2008, 'MacBook Air', 'June 8, 2009'],\n",
" 'MacBook Air (Late 2010)': [10-20-2010, 'MacBook Air', 'July 20, 2011'],\n",
" 'MacBook Air (Mid 2009)': [6-8-2009, 'MacBook Air', 'October 20, 2010'],\n",
" 'MacBook Air (Mid 2011)': [7-20-2011, 'MacBook Air', 'June 11, 2012'],\n",
" 'MacBook Air (Mid 2012)': [6-11-2012, 'MacBook Air', 'current'],\n",
" 'MacBook Air External SuperDrive': [1-15-2008, 'Drives', 'current'],\n",
" 'MacBook Pro (15\")': [2-14-2006, 'MacBook Pro', 'February 26, 2008'],\n",
" 'MacBook Pro (17\")': [4-24-2006, 'MacBook Pro', 'February 26, 2008'],\n",
" 'MacBook Pro (Early 2008) (15\")': [2-26-2008,\n",
" 'MacBook Pro',\n",
" 'October 14, 2008'],\n",
" 'MacBook Pro (Early 2008) (17\")': [2-26-2008,\n",
" 'MacBook Pro',\n",
" 'January 6, 2009'],\n",
" u'MacBook Pro (Early 2009) (17\")': [1-6-2009,\n",
" u'MacBook Pro',\n",
" u'June 8, 2009'],\n",
" 'MacBook Pro (Early 2011)': [2-24-2011, 'MacBook Pro', 'October 24, 2011'],\n",
" 'MacBook Pro (Late 2008) (15\")': [10-14-2008, 'MacBook Pro', 'June 8, 2009'],\n",
" 'MacBook Pro (Late 2011)': [10-24-2011, 'MacBook Pro', 'June 11, 2012'],\n",
" 'MacBook Pro (Mid 2009)': [6-8-2009, 'MacBook Pro', 'April 13, 2010'],\n",
" 'MacBook Pro (Mid 2010)': [4-13-2010, 'MacBook Pro', 'February 24, 2011'],\n",
" 'MacBook Pro (Mid 2012)': [6-11-2012, 'MacBook Pro', 'current'],\n",
" 'MacPaint 1.0': [1-24-1984, 'Software', ''],\n",
" 'MacWrite 1.0': [1-24-1984, 'Software', ''],\n",
" 'Macintosh (128K)': [1-24-1984, 'Compact', 'September 10, 1984'],\n",
" 'Macintosh 128K (revised)': [9-10-1984, 'Compact', 'October 1, 1985'],\n",
" 'Macintosh 512K': [9-10-1984, 'Compact', 'April 14, 1986'],\n",
" 'Macintosh 512Ke': [4-14-1986, 'Compact', 'October 1, 1987'],\n",
" 'Macintosh 800K External Drive': [1-16-1986, 'Drives', ''],\n",
" 'Macintosh Classic': [10-15-1990, 'Compact', 'September 14, 1992'],\n",
" 'Macintosh Classic II': [10-21-1991, 'Compact', 'September 13, 1993'],\n",
" 'Macintosh Color Classic': [2-10-1993, 'Compact', 'May 16, 1994'],\n",
" 'Macintosh Color Classic II': [10-10-1993, 'Compact', 'November 1, 1995'],\n",
" 'Macintosh External Disk Drive (400K)': [1-24-1984,\n",
" 'Drives',\n",
" 'January 1, 1986'],\n",
" 'Macintosh Hard Disk 20': [9-1-1985, 'Drives', ''],\n",
" 'Macintosh II': [3-2-1987, 'Mac II', 'January 15, 1990'],\n",
" 'Macintosh IIci': [9-20-1989, 'Mac II', 'February 20, 1993'],\n",
" 'Macintosh IIcx': [3-7-1989, 'Mac II', 'March 11, 1991'],\n",
" u'Macintosh IIfx': [3-19-1990, u'Mac II', u'April 15, 1992'],\n",
" 'Macintosh IIsi': [10-15-1990, 'Mac II', 'March 15, 1993'],\n",
" 'Macintosh IIvi': [10-19-1992, 'Mac II', 'February 10, 1993'],\n",
" 'Macintosh IIvx': [10-19-1992, 'Mac II', 'October 10, 1993'],\n",
" 'Macintosh IIx': [9-19-1988, 'Mac II', 'October 15, 1990'],\n",
" 'Macintosh LC': [10-15-1990, 'LC', 'March 23, 1992'],\n",
" 'Macintosh LC 520': [6-28-1993, 'LC', 'February 2, 1994'],\n",
" u'Macintosh LC 550': [2-2-1994, u'LC', u'March 23, 1995'],\n",
" 'Macintosh LC 575': [2-2-1994, 'LC', 'April 3, 1995'],\n",
" 'Macintosh LC 580': [4-3-1995, 'LC', 'October 1, 1995'],\n",
" u'Macintosh LC II': [3-23-1992, u'LC', u'March 15, 1993'],\n",
" u'Macintosh LC III / III+': [2-10-1993, u'LC', u'February 14, 1994'],\n",
" u'Macintosh Plus': [1-16-1986, u'Compact', u'October 15, 1990'],\n",
" u'Macintosh Plus (Platinum)': [1-1-1987, u'Compact', u'October 15, 1990'],\n",
" 'Macintosh Portable': [9-20-1989, 'Portable', 'February 11, 1991'],\n",
" u'Macintosh Portable (backlit screen)': [2-11-1991,\n",
" u'Portable',\n",
" u'October 21, 1991'],\n",
" 'Macintosh SE': [3-2-1987, 'Compact', 'August 1, 1989'],\n",
" 'Macintosh SE FDHD': [8-1-1989, 'Compact', 'October 15, 1990'],\n",
" u'Macintosh SE/30': [1-19-1989, u'Compact', u'October 21, 1991'],\n",
" 'Macintosh Server G3': [3-2-1998, 'Macintosh Server', 'January 1, 1999'],\n",
" 'Macintosh Server G3 (Blue & White)': [1-5-1999,\n",
" 'Macintosh Server',\n",
" 'August 31, 1999'],\n",
" 'Macintosh Server G4': [8-31-1999, 'Macintosh Server', 'July 19, 2000'],\n",
" 'Macintosh Server G4 MDD': [8-27-2002,\n",
" 'Macintosh Server',\n",
" 'January 28, 2003'],\n",
" 'Macintosh TV': [10-21-1993, 'LC', 'February 1, 1995'],\n",
" u'Macintosh XL': [1-1-1985, u'68000', u'April 1, 1985'],\n",
" 'Magic Mouse': [10-20-2009, 'Apple Mouse', 'current'],\n",
" 'Magic Trackpad': [7-27-2010, 'Trackpad', 'current'],\n",
" 'MobileMe': [7-9-2008, 'Software', 'June 30, 2012'],\n",
" 'Modem IIB (Novation CAT)': [9-1-1980, 'Modems', ''],\n",
" 'Monitor II (various third party)': [9-1-1980, 'Displays', ''],\n",
" 'Monitor III': [9-1-1980, 'Displays', ''],\n",
" 'Newton Message Pad': [8-16-1993, 'Newton', 'March 1, 1994'],\n",
" 'Nike+iPod': [7-13-2006, 'iPod Accessories', 'current'],\n",
" 'OS X Mountain Lion (10.8)': [7-25-2012, 'Software', 'current'],\n",
" 'Performa 5260 / 5300': [3-10-1996, 'Performa', 'April 1, 1997'],\n",
" 'Performa 5400': [4-1-1996, 'Performa', 'February 17, 1997'],\n",
" 'Performa 6360': [10-17-1996, 'Performa', 'October 1, 1997'],\n",
" 'Performa 6400': [10-23-1996, 'Performa', 'May 1, 1997'],\n",
" 'Pippin': [12-1-1994, 'Pippin', 'December 1, 1997'],\n",
" 'Power Macintosh 4400': [11-15-1996, 'Power Macintosh', 'October 11, 1997'],\n",
" u'Power Macintosh 5500': [2-17-1997, u'Power Macintosh', u'March 31, 1998'],\n",
" 'Power Macintosh 6100': [3-14-1994, 'Power Macintosh', 'May 18, 1996'],\n",
" u'Power Macintosh 6200 / 6300': [1-28-1995,\n",
" u'Power Macintosh',\n",
" u'October 17, 1996'],\n",
" 'Power Macintosh 6500': [2-17-1997, 'Power Macintosh', 'March 14, 1998'],\n",
" 'Power Macintosh 7100': [3-14-1994, 'Power Macintosh', 'January 6, 1996'],\n",
" 'Power Macintosh 7200': [8-7-1995, 'Power Macintosh', 'April 1, 1996'],\n",
" 'Power Macintosh 7300': [2-17-1997, 'Power Macintosh', 'November 10, 1997'],\n",
" 'Power Macintosh 7500': [8-7-1995, 'Power Macintosh', 'February 17, 1997'],\n",
" 'Power Macintosh 7600': [4-1-1996, 'Power Macintosh', 'October 1, 1997'],\n",
" 'Power Macintosh 8100': [3-14-1994, 'Power Macintosh', 'August 14, 1996'],\n",
" 'Power Macintosh 8500': [8-7-1995, 'Power Macintosh', 'February 17, 1997'],\n",
" 'Power Macintosh 8600': [2-17-1997, 'Power Macintosh', 'February 17, 1998'],\n",
" 'Power Macintosh 9500': [6-19-1995, 'Power Macintosh', 'February 17, 1997'],\n",
" 'Power Macintosh 9600': [2-17-1997, 'Power Macintosh', 'March 17, 1998'],\n",
" u'Power Macintosh G3 (Blue & White)': [1-5-1999,\n",
" u'Power Macintosh',\n",
" u'October 13, 1999'],\n",
" u'Power Macintosh G3 AIO': [1-31-1998,\n",
" u'Power Macintosh',\n",
" u'October 17, 1998'],\n",
" 'Power Macintosh G3 desktop': [11-10-1997,\n",
" 'Power Macintosh',\n",
" 'January 5, 1999'],\n",
" 'Power Macintosh G3 minitower': [11-10-1997,\n",
" 'Power Macintosh',\n",
" 'January 5, 1999'],\n",
" 'Power Macintosh G4 Cube': [7-19-2000, 'Power Macintosh', 'July 3, 2001'],\n",
" 'Power Macintosh G4 Graphite': [10-13-1999,\n",
" 'Power Macintosh',\n",
" 'July 18, 2001'],\n",
" 'Power Macintosh G4 MDD': [8-13-2002, 'Power Macintosh', 'June 9, 2004'],\n",
" 'Power Macintosh G4 Quicksilver': [7-18-2001,\n",
" 'Power Macintosh',\n",
" 'August 13, 2002'],\n",
" 'Power Macintosh G5': [6-23-2003, 'Power Macintosh', 'June 9, 2004'],\n",
" 'Power Macintosh G5 FX': [6-9-2004, 'Power Macintosh', 'October 19, 2005'],\n",
" 'Power Macintosh G5 dual core': [10-19-2005,\n",
" 'Power Macintosh',\n",
" 'August 7, 2006'],\n",
" 'Power Macintosh/Performa 5200': [4-3-1995, 'Performa', 'October 1, 1996'],\n",
" 'Power Macintosh/Performa 5300': [8-28-1995, 'Performa', 'March 1, 1997'],\n",
" u'PowerBook (\"Pismo\")': [2-16-2000, u'PowerBook G3', u'January 9, 2001'],\n",
" 'PowerBook 100': [10-21-1991, 'PowerBook', 'August 3, 1992'],\n",
" 'PowerBook 140': [10-21-1991, 'PowerBook', 'August 3, 1992'],\n",
" 'PowerBook 1400': [11-20-1996, 'PowerBook', 'May 6, 1998'],\n",
" 'PowerBook 145': [8-3-1992, 'PowerBook', 'July 7, 1993'],\n",
" 'PowerBook 145b': [6-7-1993, 'PowerBook', 'July 18, 1994'],\n",
" 'PowerBook 150': [7-18-1994, 'PowerBook', 'October 14, 1995'],\n",
" 'PowerBook 160': [10-19-1992, 'PowerBook', 'August 16, 1993'],\n",
" 'PowerBook 165': [8-16-1993, 'PowerBook', 'July 18, 1994'],\n",
" 'PowerBook 165c': [2-10-1993, 'PowerBook', 'December 13, 1993'],\n",
" 'PowerBook 170': [10-21-1991, 'PowerBook', 'October 19, 1992'],\n",
" 'PowerBook 180': [10-19-1992, 'PowerBook', 'May 16, 1994'],\n",
" 'PowerBook 180c': [6-7-1993, 'PowerBook', 'March 14, 1994'],\n",
" 'PowerBook 190': [8-28-1995, 'PowerBook', 'September 1, 1996'],\n",
" 'PowerBook 2400c': [5-8-1997, 'PowerBook', 'March 14, 1998'],\n",
" 'PowerBook 3400': [2-17-1997, 'PowerBook', 'March 14, 1998'],\n",
" 'PowerBook 520/c': [5-16-1994, 'PowerBook 500', 'September 16, 1995'],\n",
" 'PowerBook 5300': [8-28-1995, 'PowerBook', 'September 1, 1996'],\n",
" 'PowerBook 540/c': [5-16-1994, 'PowerBook 500', 'August 16, 1995'],\n",
" 'PowerBook 550': [5-16-1994, 'PowerBook 500', 'April 1, 1996'],\n",
" 'PowerBook Duo 210': [10-19-1992, 'PowerBook Duo', 'October 21, 1993'],\n",
" 'PowerBook Duo 230': [10-19-1992, 'PowerBook Duo', 'July 27, 1994'],\n",
" 'PowerBook Duo 2300c': [8-28-1995, 'PowerBook Duo', 'February 1, 1997'],\n",
" 'PowerBook Duo 250': [10-21-1993, 'PowerBook Duo', 'May 16, 1994'],\n",
" 'PowerBook Duo 270c': [10-21-1993, 'PowerBook Duo', 'May 16, 1994'],\n",
" 'PowerBook Duo 280': [5-16-1994, 'PowerBook Duo', 'November 14, 1994'],\n",
" 'PowerBook Duo 280c': [5-16-1994, 'PowerBook Duo', 'January 1, 1996'],\n",
" 'PowerBook G3': [11-10-1997, 'PowerBook G3', 'March 14, 1998'],\n",
" 'PowerBook G3 (\"Lombard\")': [5-10-1999, 'PowerBook G3', 'February 16, 2000'],\n",
" 'PowerBook G3 series': [5-6-1998, 'PowerBook G3', 'May 10, 1999'],\n",
" u'PowerBook G4 Aluminum (12\")': [1-7-2003, u'PowerBook G4', u'May 16, 2006'],\n",
" 'PowerBook G4 Aluminum (15\")': [9-16-2003,\n",
" 'PowerBook G4',\n",
" 'February 14, 2006'],\n",
" 'PowerBook G4 Aluminum (17\")': [1-7-2003, 'PowerBook G4', 'April 24, 2006'],\n",
" u'PowerBook G4 Titanium': [1-00-2001, u'PowerBook G4', u'September 16, 2003'],\n",
" 'PowerCD': [3-22-1993, 'PowerCD', 'January 1, 1995'],\n",
" 'Printer IIA (Centronics 779)': [9-1-1980, 'Printers', ''],\n",
" 'Quadra 605': [10-21-1993, 'Quadra', 'October 17, 1994'],\n",
" 'Quadra 610': [10-21-1993, 'Quadra', 'July 18, 1994'],\n",
" 'Quadra 630': [7-18-1994, 'Quadra', 'April 17, 1995'],\n",
" 'Quadra 650': [10-21-1993, 'Quadra', 'September 12, 1994'],\n",
" 'Quadra 700': [10-21-1991, 'Quadra', 'March 15, 1993'],\n",
" 'Quadra 800': [2-10-1993, 'Quadra', 'March 14, 1994'],\n",
" 'Quadra 840AV': [7-29-1993, 'Quadra', 'July 18, 1994'],\n",
" 'Quadra 900': [10-21-1991, 'Quadra', 'May 18, 1992'],\n",
" 'Quadra 950': [5-18-1992, 'Quadra', 'October 14, 1995'],\n",
" u'Retina MacBook Pro': [2-13-2013, u'MacBook Pro', u'current'],\n",
" 'Retina MacBook Pro (3rd gen) (13\")': [10-23-2012, 'MacBook Pro', 'current'],\n",
" 'Retina MacBook Pro (3rd gen) (15\")': [6-11-2012,\n",
" 'MacBook Pro',\n",
" 'February 13, 2013'],\n",
" 'Server G4 Quicksilver': [9-8-2001, 'Macintosh Server', 'May 14, 2002'],\n",
" 'Shake 4': [6-20-2006, 'Software', 'July 30, 2009'],\n",
" 'Thunderbolt Display': [7-20-2011, 'Displays', 'current'],\n",
" 'Time Capsule (1st gen)': [2-29-2008, 'AirPort, drives', 'March 3, 2009'],\n",
" 'Time Capsule (2nd gen) (1 TB)': [3-3-2009,\n",
" 'AirPort, drives',\n",
" 'March 31, 2010'],\n",
" 'Time Capsule (2nd gen) (2 TB)': [7-30-2009,\n",
" 'AirPort, drives',\n",
" 'March 31, 2010'],\n",
" 'Time Capsule (2nd gen) (500 GB)': [3-3-2009,\n",
" 'AirPort, drives',\n",
" 'July 30, 2009'],\n",
" 'Time Capsule (3rd gen)': [3-31-2010, 'AirPort, drives', 'June 21, 2011'],\n",
" 'Time Capsule (4th gen)': [6-21-2011, 'AirPort, drives', 'current'],\n",
" 'Twentieth Anniversary Macintosh': [3-20-1997,\n",
" 'Power Macintosh',\n",
" 'March 14, 1998'],\n",
" 'Workgroup Server 60': [7-26-1993, 'Workgroup Server', 'October 17, 1995'],\n",
" 'Workgroup Server 6150': [4-26-1994, 'Workgroup Server', 'October 1, 1995'],\n",
" 'Workgroup Server 7250': [2-26-1996, 'Workgroup Server', 'April 21, 1997'],\n",
" 'Workgroup Server 7350': [4-21-1997, 'Workgroup Server', 'March 2, 1998'],\n",
" 'Workgroup Server 80': [3-22-1993, 'Workgroup Server', 'October 17, 1995'],\n",
" 'Workgroup Server 8150': [4-26-1994, 'Workgroup Server', 'February 26, 1996'],\n",
" 'Workgroup Server 8550': [2-26-1996, 'Workgroup Server', 'April 21, 1997'],\n",
" 'Workgroup Server 9150': [4-26-1994, 'Workgroup Server', 'February 26, 1996'],\n",
" 'Workgroup Server 95': [3-22-1993, 'Workgroup Server', 'April 3, 1995'],\n",
" 'Workgroup Server 9650': [4-21-1997, 'Workgroup Server', 'March 2, 1998'],\n",
" 'Xsan 2': [2-19-2008, 'Software', 'current'],\n",
" 'Xserve': [5-14-2002, 'Xserve', 'February 10, 2003'],\n",
" 'Xserve (2009)': [4-7-2009, 'Xserve', 'January 31, 2011'],\n",
" u'Xserve (Early 2008)': [1-8-2008, u'Xserve', u'April 7, 2009'],\n",
" 'Xserve (Intel)': [8-7-2006, 'Xserve', 'January 8, 2008'],\n",
" 'Xserve Cluster Node': [2-10-2003, 'Xserve', 'January 6, 2004'],\n",
" 'Xserve Cluster Node G5': [1-6-2004, 'Xserve', 'August 7, 2006'],\n",
" u'Xserve G5': [1-6-2004, u'Xserve', u'August 7, 2006'],\n",
" 'Xserve slot loading': [2-10-2003, 'Xserve', 'January 6, 2004'],\n",
" 'eMac': [4-29-2002, 'eMac', 'July 5, 2006'],\n",
" 'eMate 300': [3-7-1997, 'Newton', 'February 27, 1998'],\n",
" 'iBook': [7-21-1999, 'iBook', 'September 13, 2000'],\n",
" 'iBook (14\")': [1-7-2002, 'iBook', 'October 22, 2003'],\n",
" 'iBook (FireWire)': [9-13-2000, 'iBook', 'May 1, 2001'],\n",
" 'iBook (white)': [5-1-2001, 'iBook', 'October 2003'],\n",
" 'iBook G4 (12\" / 14\")': [10-22-2003, 'iBook', 'May 16, 2006'],\n",
" u'iBooks Author': [1-19-2012, u'Software', u'current'],\n",
" 'iCloud': [10-12-2011, 'Software', 'current'],\n",
" \"iLife '09\": [1-27-2009, 'Software', 'October 20, 2010'],\n",
" \"iLife '11\": [10-20-2010, 'Software', 'current'],\n",
" 'iMac (21.5\") (Late 2012)': [11-30-2012, 'iMac', 'current'],\n",
" 'iMac (27\") (Late 2012)': [12-00-2012, 'iMac', 'current'],\n",
" u'iMac (Early 2006)': [1-10-2006, u'iMac', u'September 6, 2006'],\n",
" 'iMac (Early 2008)': [4-28-2008, 'iMac', 'March 3, 2009'],\n",
" 'iMac (Early 2009)': [3-3-2009, 'iMac', 'October 20, 2009'],\n",
" 'iMac (Late 2009)': [10-20-2009, 'iMac', 'July 27, 2010'],\n",
" 'iMac (Mid 2006)': [9-6-2006, 'iMac', 'August 7, 2007'],\n",
" 'iMac (Mid 2007)': [8-7-2007, 'iMac', 'April 28, 2008'],\n",
" 'iMac (Mid 2011)': [5-3-2011, 'iMac', 'November 30, 2012'],\n",
" 'iMac (slot loading)': [10-5-1999, 'iMac', 'January 7, 2002'],\n",
" 'iMac G3': [8-15-1998, 'iMac', 'May 10, 1999'],\n",
" u'iMac G4 15\"': [1-7-2002, u'iMac', u'August 31, 2004'],\n",
" 'iMac G4 17\"': [7-17-2002, 'iMac', 'August 31, 2004'],\n",
" 'iMac G4 20\"': [11-18-2003, 'iMac', 'August 31, 2004'],\n",
" 'iMac G5 17\"': [8-31-2004, 'iMac', 'January 10, 2006'],\n",
" 'iMac G5 20\"': [8-31-2004, 'iMac', 'March 20, 2006'],\n",
" 'iOS 5': [10-12-2011, 'Software', 'September 19, 2012'],\n",
" 'iOS 6': [9-19-2012, 'Software', 'current'],\n",
" 'iPad (3rd gen)': [3-16-2012, 'iPad', 'October 23, 2012'],\n",
" 'iPad (4th gen) (Wi-Fi + Cellular)': [11-16-2012, 'iPad', 'current'],\n",
" 'iPad (4th gen) (Wi-Fi)': [11-2-2012, 'iPad', 'current'],\n",
" 'iPad (Wi-Fi + 3G)': [4-30-2010, 'iPad', 'March 2, 2011'],\n",
" 'iPad (Wi-Fi)': [4-3-2010, 'iPad', 'March 2, 2011'],\n",
" 'iPad 2 (16 GB)': [3-11-2011, 'iPad', 'current'],\n",
" 'iPad 2 (32 & 64 GB)': [3-11-2011, 'iPad', 'March 7, 2012'],\n",
" 'iPad Mini (Wi-Fi + Cellular)': [11-16-2012, 'iPad', 'current'],\n",
" 'iPad Mini (Wi-Fi)': [11-2-2012, 'iPad', 'current'],\n",
" 'iPhone (1st generation)': [6-29-2007, 'iPhone', 'July 11, 2008'],\n",
" 'iPhone 3G (16 GB)': [7-11-2008, 'iPhone', 'June 19, 2009'],\n",
" 'iPhone 3G (8 GB)': [7-11-2008, 'iPhone', 'June 24, 2010'],\n",
" 'iPhone 3GS (16 & 32 GB)': [6-19-2009, 'iPhone', 'June 24, 2010'],\n",
" 'iPhone 3GS (8 GB)': [6-24-2010, 'iPhone', 'September 12, 2012'],\n",
" 'iPhone 4 (8 GB)': [10-14-2011, 'iPhone', 'current'],\n",
" u'iPhone 4 (CDMA) (16 & 32 GB)': [2-10-2011, u'iPhone', u'October 4, 2011'],\n",
" 'iPhone 4 (GSM) (16 & 32 GB)': [6-24-2010, 'iPhone', 'October 4, 2011'],\n",
" 'iPhone 4S (16 GB)': [10-14-2011, 'iPhone', 'current'],\n",
" 'iPhone 4S (32 & 64 GB)': [10-14-2011, 'iPhone', 'September 12, 2012'],\n",
" 'iPhone 5': [9-21-2012, 'iPhone', 'current'],\n",
" 'iPhone Micro USB Adapter': [10-14-2011, 'iPhone', 'current'],\n",
" 'iPod (2nd gen)': [7-17-2002, 'iPod Classic', 'April 28, 2003'],\n",
" 'iPod (3rd gen)': [4-00-28, 'iPod Classic', 'July 19, 2004'],\n",
" 'iPod (4th gen)': [7-00-19, 'iPod Classic', 'October 12, 2005'],\n",
" 'iPod (5th gen)': [10-12-2005, 'iPod Classic', 'September 5, 2007'],\n",
" 'iPod (st gen)': [10-23-2001, 'iPod Classic', 'July 17, 2002'],\n",
" 'iPod Classic (6th gen)': [9-5-2007, 'iPod Classic', 'September 9, 2008'],\n",
" 'iPod Classic (6th gen) (120 GB)': [9-9-2008,\n",
" 'iPod Classic',\n",
" 'September 9, 2009'],\n",
" 'iPod Classic (6th gen) (160 GB)': [9-9-2009, 'iPod Classic', 'current'],\n",
" 'iPod Mini (1st gen)': [1-6-2004, 'iPod Mini', 'February 23, 2005'],\n",
" 'iPod Mini (2nd gen)': [2-23-2005, 'iPod Mini', 'September 7, 2005'],\n",
" 'iPod Nano (3rd gen)': [9-5-2007, 'iPod Nano', 'September 6, 2008'],\n",
" 'iPod Nano (4th gen)': [9-9-2008, 'iPod Nano', 'September 9, 2009'],\n",
" 'iPod Nano (5th gen)': [9-9-2009, 'iPod Nano', 'September 1, 2010'],\n",
" 'iPod Nano (6th gen)': [9-1-2010, 'iPod Nano', 'September 12, 2012'],\n",
" 'iPod Nano (7th gen)': [10-11-2012, 'iPod Nano', 'current'],\n",
" 'iPod Photo': [9-26-2004, 'iPod Classic', 'June 28, 2005'],\n",
" 'iPod Radio Remote': [1-10-2006, 'iPod Accessories', 'June 25, 2009'],\n",
" 'iPod Shuffle (1st gen)': [1-11-2005, 'iPod Shuffle', 'September 12, 2006'],\n",
" 'iPod Shuffle (2nd gen)': [9-00-12, 'iPod Shuffle', 'March 11, 2009'],\n",
" 'iPod Shuffle (3rd gen) (2 GB)': [9-9-2009,\n",
" 'iPod Shuffle',\n",
" 'September 1, 2010'],\n",
" 'iPod Shuffle (3rd gen) (4 GB)': [3-11-2009,\n",
" 'iPod Shuffle',\n",
" 'September 1, 2010'],\n",
" 'iPod Shuffle (4th gen)': [9-1-2010, 'iPod Shuffle', 'current'],\n",
" 'iPod Touch (1st gen) (32 GB)': [2-27-2008,\n",
" 'iPod Touch',\n",
" 'September 9, 2008'],\n",
" 'iPod Touch (1st gen) (8 & 16 GB)': [9-5-2007,\n",
" 'iPod Touch',\n",
" 'September 9, 2008'],\n",
" 'iPod Touch (2nd gen) (16 & 32 GB)': [9-9-2008,\n",
" 'iPod Touch',\n",
" 'September 9, 2009'],\n",
" 'iPod Touch (2nd gen) (8 GB)': [9-9-2008, 'iPod Touch', 'September 1, 2010'],\n",
" 'iPod Touch (3rd gen)': [9-9-2009, 'iPod Touch', 'September 1, 2010'],\n",
" 'iPod Touch (4th gen) (16 GB)': [9-12-2012, 'iPod Touch', 'current'],\n",
" 'iPod Touch (4th gen) (32 GB)': [9-1-2010, 'iPod Touch', 'current'],\n",
" 'iPod Touch (4th gen) (8 & 64 GB)': [9-1-2010,\n",
" 'iPod Touch',\n",
" 'September 12, 2012'],\n",
" 'iPod Touch (5th gen)': [10-11-2012, 'iPod Touch', 'current'],\n",
" 'iPod+HP': [1-8-2004, 'iPod Classic', 'July 29, 2005'],\n",
" \"iWork '09\": [1-6-2009, 'Software', 'current']}"
]
}
],
"prompt_number": 3
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Print first ten of each category we just scraped."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"timeline = getProductReleasesForApple()\n",
"\n",
"sortedTimeline = sorted(timeline.items(),key=lambda tup: tup[1][0].numericDate())\n",
"productName = []\n",
"family = []\n",
"releaseDate = []\n",
"discontinueDate = []\n",
"for item in sortedTimeline:\n",
" productName.append(item[0])\n",
" releaseDate.append(item[1][0])\n",
" family.append(item[1][1])\n",
" discontinueDate.append(item[1][2])\n",
" \n",
"print productName[:10]\n",
"print\n",
"# print releaseDate[:10]\n",
"# print\n",
"print family[:10]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"['iPod Shuffle (2nd gen)', 'iPod (4th gen)', 'iPod (3rd gen)', u'Apple I', u'Apple II', u'Disk II', 'Apple Writer 1.0', 'Apple SilenType', 'Apple II EuroPlus', 'Apple II J-Plus']\n",
"\n",
"['iPod Shuffle', 'iPod Classic', 'iPod Classic', u'Apple I', u'Apple II', u'Drives', 'Software', 'Printers', 'Apple II', 'Apple II']\n"
]
}
],
"prompt_number": 4
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Query Class"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We've defined a separate query class for handling the different kinds of queries. We have looking up a single product, a family of products, and a more general time range."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"class Query:\n",
" #queryTypes: \"timerange, family, product\"\n",
" def __init__(self, queryType, arg, daysPadding=5):\n",
" self.daysPadding = daysPadding\n",
" self.symbol = \"AAPL\"\n",
" self.queryType = queryType\n",
" self.arg = arg\n",
"\n",
" # set up the dataFrame\n",
" if queryType==\"timerange\":\n",
" self.startDate = arg[0].dateRange(daysPadding)[0]\n",
" self.endDate = arg[1].dateRange(daysPadding)[1]\n",
" # self.dateBoundary()\n",
" criterion = timelineDataFrame['Release Date'].map(lambda date: (date.numericDate() > self.startDate.numericDate()) and (date.numericDate() < self.endDate.numericDate()))\n",
" self.dataFrame = timelineDataFrame[criterion]\n",
" elif queryType==\"family\":\n",
" criterion = timelineDataFrame['Family'] == arg\n",
" self.dataFrame = timelineDataFrame[criterion]\n",
" for date in self.dataFrame['Release Date']:\n",
" dateRange = date.dateRange(daysPadding)\n",
" self.startDate = self.dataFrame['Release Date'][0].dateRange(daysPadding)[0]\n",
" self.endDate = self.dataFrame['Release Date'][-1].dateRange(daysPadding)[1]\n",
" # self.dateBoundary()\n",
" elif queryType==\"product\":\n",
" self.dataFrame = timelineDataFrame[timelineDataFrame.index == arg]\n",
" dateRange = self.dataFrame['Release Date'][0].dateRange(daysPadding)\n",
" self.startDate = dateRange[0]\n",
" self.endDate = dateRange[1]\n",
" # self.dateBoundary()\n",
" else:\n",
" print \"invalid queryType\"\n",
"\n",
" self.setStockData()\n",
" # print self.dataFrame\n",
"\n",
" def plotIndividualStockDifferences(self):\n",
" import matplotlib.pyplot as plt\n",
" plot = mouseHoverPlot(self.dataFrame['Individual Stock Difference'], self.dataFrame, 'Individual Stock Difference')\n",
" pl.ylabel('Stock Difference over %d day(s) in dollars' % self.daysPadding)\n",
" pl.xlabel('Product Names')\n",
" pl.show()\n",
"\n",
" def plotSlopeChanges(self):\n",
" import matplotlib.pyplot as plt\n",
" plot = mouseHoverPlot(self.dataFrame['Stock Slope Change'], self.dataFrame, 'Stock Slope Change')\n",
" pl.ylabel('Stock slope changes over %d day(s) in dollars' % self.daysPadding)\n",
" pl.xlabel('Product Names')\n",
" pl.show()\n",
"\n",
" def getIndividualStock(self, releaseDate):\n",
" dateRange = releaseDate.dateRange(self.daysPadding)\n",
" startIndividualDate = dateRange[0]\n",
" endIndividualDate = dateRange[1]\n",
"\n",
" interval = 'd'\n",
" url = \"http://ichart.yahoo.com/table.csv?s=%s&a=%i&b=%i&c=%i&d=%i&e=%i&f=%i&g=%s&ignore=.csv\" \\\n",
" % ( self.symbol, startIndividualDate.m-1, startIndividualDate.d, startIndividualDate.y, endIndividualDate.m-1, endIndividualDate.d, endIndividualDate.y, interval)\n",
" from time import sleep\n",
" \n",
" u = urllib.urlopen(url)\n",
" \n",
" ulines = u.read().split(\"\\n\")\n",
" start = ulines[-2]\n",
" end = ulines[1]\n",
" \n",
" difference = parse_yahoo_stock(end)['Close'] - parse_yahoo_stock(start)['Close']\n",
" # print 'getIndividualStock works'\n",
" if difference > 0:\n",
" sign = '+'\n",
" else:\n",
" sign = '-'\n",
" #print sign + str(difference) \n",
" return difference\n",
"\n",
" def getRangeStockData(self):\n",
" interval = 'd'\n",
"\n",
" url = \"http://ichart.yahoo.com/table.csv?s=%s&a=%i&b=%i&c=%i&d=%i&e=%i&f=%i&g=%s&ignore=.csv\" \\\n",
" % ( self.symbol, self.startDate.m-1, self.startDate.d, self.startDate.y, self.endDate.m-1, self.endDate.d, self.endDate.y, interval)\n",
" from time import sleep\n",
" \n",
" u = urllib.urlopen(url)\n",
" \n",
" ulines = u.read().split(\"\\n\")\n",
" start = ulines[-2]\n",
" end = ulines[1]\n",
" \n",
" difference = parse_yahoo_stock(end)['Close'] - parse_yahoo_stock(start)['Close']\n",
" # print 'rangestockdata works'\n",
" if difference > 0:\n",
" sign = '+'\n",
" else:\n",
" sign = '-'\n",
" #print sign + str(difference) \n",
" return difference\n",
"\n",
" def getStockSlope(self, releaseDate):\n",
" interval = 'd'\n",
" startDate = releaseDate.dateRange(self.daysPadding)[0]\n",
" endDate = releaseDate.dateRange(self.daysPadding)[1]\n",
"\n",
" # print self.dataFrame\n",
"\n",
" url = \"http://ichart.yahoo.com/table.csv?s=%s&a=%i&b=%i&c=%i&d=%i&e=%i&f=%i&g=%s&ignore=.csv\" \\\n",
" % ( self.symbol, startDate.m-1, startDate.d, startDate.y, releaseDate.m-1, releaseDate.d, releaseDate.y, interval)\n",
" from time import sleep\n",
" u = urllib.urlopen(url)\n",
" ulines = u.read().split(\"\\n\")\n",
" start = ulines[-2]\n",
" end = ulines[1]\n",
" # print end\n",
" # print self.startDate\n",
" # print releaseDate\n",
" # print self.endDate\n",
" # print 'about to start stockSlopes'\n",
" # print 'startDate: ', startDate\n",
" # print 'releaseDate: ', releaseDate\n",
" # print 'endDate: ', endDate\n",
" # print start,end\n",
" # print parse_yahoo_stock(end)\n",
" leadingDifference = parse_yahoo_stock(end)['Close'] - parse_yahoo_stock(start)['Close']\n",
" # print 'getstockslope part 1 works'\n",
" leadingSlope = leadingDifference / self.daysPadding\n",
" \n",
" url = \"http://ichart.yahoo.com/table.csv?s=%s&a=%i&b=%i&c=%i&d=%i&e=%i&f=%i&g=%s&ignore=.csv\" \\\n",
" % ( self.symbol, releaseDate.m-1, releaseDate.d, releaseDate.y, endDate.m-1, endDate.d, endDate.y, interval)\n",
" # from time import sleep\n",
" u = urllib.urlopen(url)\n",
" ulines = u.read().split(\"\\n\")\n",
" start = ulines[-2]\n",
" end = ulines[1]\n",
" leavingDifference = parse_yahoo_stock(end)['Close'] - parse_yahoo_stock(start)['Close']\n",
" # print 'getstockslope part 2 works'\n",
" leavingSlope = leavingDifference / self.daysPadding\n",
" # print start,end\n",
"\n",
" slopeDifference = leavingSlope - leadingSlope\n",
" return slopeDifference \n",
"\n",
" def setStockData(self): # should set both RangeStock and IndividualStock\n",
" rangeStockImpact = self.getRangeStockData()\n",
" # print 'set rangeStockData'\n",
" self.dataFrame['Range Stock Difference'] = rangeStockImpact\n",
" indivStocks = []\n",
" stockSlopes = []\n",
" for date in self.dataFrame['Release Date']:\n",
" indivStocks.append(self.getIndividualStock(date))\n",
" stockSlopes.append(self.getStockSlope(date))\n",
" self.dataFrame['Individual Stock Difference'] = indivStocks\n",
" # print 'set individual stock'\n",
" self.dataFrame['Stock Slope Change'] = stockSlopes\n",
" # print 'set stock slopes'\n",
" \n",
" #returns row of most influential product\n",
" def getMostInfluencial(self):\n",
" maxIndex = self.dataFrame['Individual Stock Difference'].argmax()\n",
" maxProduct = self.dataFrame.index[maxIndex]\n",
" maxProductRow = self.dataFrame[self.dataFrame.index == maxProduct]\n",
" return maxProductRow"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 5
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Special bit we needed for enabling mouse over hover on the plot."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import matplotlib as plt\n",
"plt.use('WXAgg')\n",
"plt.interactive(False)\n",
"\n",
"class mouseHoverPlot(object):\n",
" def __init__(self, dataY, dataFrame, plotType):\n",
" import pylab as pl\n",
" from pylab import get_current_fig_manager as gcfm\n",
" import wx\n",
" import numpy as np\n",
" import random\n",
"\n",
" self.plotType = plotType\n",
" self.dataFrame = dataFrame\n",
" self.figure = pl.figure()\n",
" self.axis = self.figure.add_subplot(111)\n",
" # create a long tooltip with newline to get around wx bug (in v2.6.3.3)\n",
" # where newlines aren't recognized on subsequent self.tooltip.SetTip() calls\n",
" self.tooltip = wx.ToolTip(tip='tip with a long %s line and a newline\\n' % (' '*100))\n",
" gcfm().canvas.SetToolTip(self.tooltip)\n",
" self.tooltip.Enable(False)\n",
" self.tooltip.SetDelay(0)\n",
" self.figure.canvas.mpl_connect('motion_notify_event', self._onMotion)\n",
" self.dataX = range(len(dataY))\n",
" self.dataY = dataY\n",
" self.xTicks = dataFrame.index\n",
" pl.xticks(self.dataX, self.xTicks)\n",
" self.axis.plot(self.dataX, self.dataY, linestyle='-', marker='o', markersize=15, label='myplot')\n",
"\n",
" def _onMotion(self, event):\n",
" collisionFound = False\n",
" if event.xdata != None and event.ydata != None: # mouse is inside the axes\n",
" for i in xrange(len(self.dataX)):\n",
" radius = .2\n",
" if abs(event.xdata - self.dataX[i]) < radius and abs(event.ydata - self.dataY[i]) < radius:\n",
" def productName(xPos):\n",
" return self.xTicks[int(round(xPos))]\n",
" # print self.dataFrame[self.dataFrame.index == productName(event.xdata)]['Release Date'][0]\n",
" top = tip='Product: %s\\nRelease Date: %s\\nStock Price Difference: $%.2f' % (productName(event.xdata),self.dataFrame[self.dataFrame.index == productName(event.xdata)]['Release Date'][0], self.dataFrame[self.dataFrame.index == productName(event.xdata)][self.plotType][0] )\n",
" self.tooltip.SetTip(tip) \n",
" self.tooltip.Enable(True)\n",
" collisionFound = True\n",
" break\n",
" if not collisionFound:\n",
" self.tooltip.Enable(False)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stderr",
"text": [
"c:\\Python27\\lib\\site-packages\\matplotlib\\__init__.py:908: UserWarning: This call to matplotlib.use() has no effect\n",
"because the the backend has already been chosen;\n",
"matplotlib.use() must be called *before* pylab, matplotlib.pyplot,\n",
"or matplotlib.backends is imported for the first time.\n",
"\n",
" if warn: warnings.warn(_use_error_msg)\n"
]
}
],
"prompt_number": 6
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Generating Options for Interacting"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div id=\"radio\">\n",
" <input type=\"radio\" id=\"radioSingleProduct\" name=\"radio\"><label for=\"radioSingleProduct\">Single Product</label>\n",
" <input type=\"radio\" id=\"radioFamily\" name=\"radio\" checked=\"checked\"><label for=\"radioFamily\">Family</label>\n",
" <input type=\"radio\" id=\"radioTimeRange\" name=\"radio\"><label for=\"radioTimeRange\">Time Range</label>\n",
"</div>\n",
"\n",
"<script>\n",
" var kernel = IPython.notebook.kernel;\n",
" kernel.execute(\"qtype = 'family'\");\n",
" $(\"#radio\").buttonset();\n",
" $('#radio :radio').click(function() {\n",
" kernel.execute(\"some_var = '\");\n",
" radioId = $(this).attr('id');\n",
" if (radioId === 'radioSingleProduct') {\n",
" selectId = 'singleProducts';\n",
" kernel.execute(\"qtype = 'singleProduct'\");\n",
" }\n",
" else if (radioId === 'radioFamily') {\n",
" selectId = 'families';\n",
" kernel.execute(\"qtype = 'family'\");\n",
" }\n",
" else if (radioId === 'radioTimeRange') {\n",
" selectId = 'timeRanges';\n",
" kernel.execute(\"qtype = 'timeRange'\");\n",
" }\n",
" $(\"#\"+\"families\").prev().css('visibility','hidden');\n",
" $(\"#\"+\"families\").css('visibility','hidden');\n",
" $(\"#\"+\"singleProducts\").prev().css('visibility','hidden');\n",
" $(\"#\"+\"singleProducts\").css('visibility','hidden');\n",
" $(\"#\"+\"timeRanges\").prev().css('visibility','hidden');\n",
" $(\"#\"+\"timeRanges\").css('visibility','hidden');\n",
" \n",
" $(\"#\"+selectId).prev().css('visibility','visible');\n",
" $(\"#\"+selectId).css('visibility','visible');\n",
" // console.log($(this).parent().append('<p>hi</p>'));\n",
" });\n",
"</script>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from IPython.core.display import HTML\n",
"selectform = \"\"\n",
"selectform += \"<p>Single Products</p>\"\n",
"selectform += \"<select id='singleProducts'>\"\n",
"# singleProducts = ['iMac (27\") (Late 2012)', 'iMac (21.5\") (Late 2012)', 'iPad (4th gen) (Wi-Fi + Cellular)', 'iPad Mini (Wi-Fi + Cellular)']\n",
"selectform += \"<option value=\\\"0\\\">----Select a Single Product----</option>\"\n",
"counter = 1\n",
"for singleProduct in productName:\n",
" selectform += \"<option value=\\\"%s\\\">%s</option>\" % (counter, singleProduct)\n",
" counter += 1\n",
"selectform += \"</select>\"\n",
"\n",
"selectform += \"<p>Families</p>\"\n",
"selectform += \"<select id='families'>\"\n",
"# families = ['iMac', 'iPad', 'MacBook Pro', 'Mac Mini']\n",
"selectform += \"<option value=\\\"0\\\">---Select a Family of Products---</option>\"\n",
"counter = 1\n",
"\n",
"for fam in list(set(family)):\n",
" selectform += \"<option value=\\\"%s\\\">%s</option>\" % (counter, fam)\n",
" counter += 1\n",
"selectform += \"</select>\"\n",
"\"var selected=$('select#singleProducts').find(':selected').text();py1='selected = &quot;'+selected+'&quot';IPython.notebook.kernel.execute(py1);\"\n",
"#selectform += \"<input type=\\\"button\\\" value=\\\"Compute\\\" onclick=\\\"var selected=$('select#singleProducts').find(':selected').text();var py1='selected = &quot;'+selected+'&quot';IPython.notebook.kernel.execute(py1);\\\">\"\n",
"\n",
"selectform += \"<p>Time Range</p>\"\n",
"selectform += \"<input type='text' id='timeRanges'/>\"\n",
"\n",
"script=\"\"\n",
"HTML(selectform+\"<script>\"+script+\"</script>\")"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<p>Single Products</p><select id='singleProducts'><option value=\"0\">----Select a Single Product----</option><option value=\"1\">iPod Shuffle (2nd gen)</option><option value=\"2\">iPod (4th gen)</option><option value=\"3\">iPod (3rd gen)</option><option value=\"4\">Apple I</option><option value=\"5\">Apple II</option><option value=\"6\">Disk II</option><option value=\"7\">Apple Writer 1.0</option><option value=\"8\">Apple SilenType</option><option value=\"9\">Apple II EuroPlus</option><option value=\"10\">Apple II J-Plus</option><option value=\"11\">Bell & Howell</option><option value=\"12\">Apple II Plus</option><option value=\"13\">Bell & Howell Disk II</option><option value=\"14\">Monitor II (various third party)</option><option value=\"15\">Printer IIA (Centronics 779)</option><option value=\"16\">Apple III</option><option value=\"17\">Monitor III</option><option value=\"18\">Disk III</option><option value=\"19\">Modem IIB (Novation CAT)</option><option value=\"20\">Apple ProFile</option><option value=\"21\">Apple III Revised[1]</option><option value=\"22\">Apple Letter Quality Printer</option><option value=\"23\">Apple Dot Matrix Printer</option><option value=\"24\">Apple IIe</option><option value=\"25\">Apple Lisa[2]</option><option value=\"26\">Apple ImageWriter</option><option value=\"27\">Apple III Plus</option><option value=\"28\">Apple Lisa 2</option><option value=\"29\">MacPaint 1.0</option><option value=\"30\">Macintosh (128K)</option><option value=\"31\">MacWrite 1.0</option><option value=\"32\">Macintosh External Disk Drive (400K)</option><option value=\"33\">Apple Modem 300</option><option value=\"34\">Apple Modem 1200</option><option value=\"35\">Apple Mouse IIc</option><option value=\"36\">Disk IIc</option><option value=\"37\">Apple IIc</option><option value=\"38\">Apple Scribe Printer</option><option value=\"39\">Apple DuoDisk 5.25</option><option value=\"40\">Apple Color Plotter</option><option value=\"41\">Apple ImageWriter Wide Carriage</option><option value=\"42\">Macintosh 128K (revised)</option><option value=\"43\">Macintosh 512K</option><option value=\"44\">AppleColor 100</option><option value=\"45\">Apple LaserWriter</option><option value=\"46\">Macintosh XL</option><option value=\"47\">Apple LocalTalk Connector</option><option value=\"48\">Apple IIe Enhanced</option><option value=\"49\">Apple ImageWriter II</option><option value=\"50\">Apple Personal Modem</option><option value=\"51\">Apple UniDisk 5.25</option><option value=\"52\">Apple UniDisk 3.5</option><option value=\"53\">Apple ColorMonitor IIc</option><option value=\"54\">Apple ColorMonitor IIe</option><option value=\"55\">Macintosh Hard Disk 20</option><option value=\"56\">Macintosh Plus</option><option value=\"57\">Apple LaserWriter Plus</option><option value=\"58\">Macintosh 800K External Drive</option><option value=\"59\">Macintosh 512Ke</option><option value=\"60\">Apple 5.25\" Drive</option><option value=\"61\">Apple IIGS</option><option value=\"62\">Apple IIc Memory Expansion</option><option value=\"63\">AppleColor RGB Monitor</option><option value=\"64\">Apple Hard Disk 20SC</option><option value=\"65\">Apple 3.5\" Drive</option><option value=\"66\">Apple Monochrome Monitor</option><option value=\"67\">AppleColor Composite Monitor</option><option value=\"68\">Macintosh Plus (Platinum)</option><option value=\"69\">AppleShare Server 1.0</option><option value=\"70\">Apple IIe Platinum</option><option value=\"71\">Macintosh SE</option><option value=\"72\">AppleColor Hi-Resolution RGB Monitor</option><option value=\"73\">Macintosh II</option><option value=\"74\">Apple Tape Backup 40SC</option><option value=\"75\">ImageWriter LQ</option><option value=\"76\">Apple PC 5.25\" Drive</option><option value=\"77\">AppleFax Modem</option><option value=\"78\">Apple LaserWriter Family</option><option value=\"79\">AppleCD SC</option><option value=\"80\">Apple Scanner</option><option value=\"81\">Apple IIc Plus</option><option value=\"82\">Macintosh IIx</option><option value=\"83\">Macintosh SE/30</option><option value=\"84\">Macintosh IIcx</option><option value=\"85\">Apple Two Page Monochrome Monitor</option><option value=\"86\">Apple Macintosh Portrait Display</option><option value=\"87\">Apple Hi-Resolution Monochrome Display</option><option value=\"88\">Apple Modem 2400</option><option value=\"89\">Macintosh SE FDHD</option><option value=\"90\">Apple FDHD SuperDrive</option><option value=\"91\">Macintosh IIci</option><option value=\"92\">Macintosh Portable</option><option value=\"93\">Apple IIGS (1 MB, ROM 3)[3]</option><option value=\"94\">Macintosh IIfx</option><option value=\"95\">Macintosh LC</option><option value=\"96\">Macintosh IIsi</option><option value=\"97\">Macintosh Classic</option><option value=\"98\">Macintosh Portable (backlit screen)</option><option value=\"99\">Apple IIe Card (requires Macintosh LC)</option><option value=\"100\">Macintosh Classic II</option><option value=\"101\">Quadra 700</option><option value=\"102\">PowerBook 140</option><option value=\"103\">Quadra 900</option><option value=\"104\">PowerBook 170</option><option value=\"105\">PowerBook 100</option><option value=\"106\">Macintosh LC II</option><option value=\"107\">Quadra 950</option><option value=\"108\">PowerBook 145</option><option value=\"109\">PowerBook Duo 230</option><option value=\"110\">PowerBook 160</option><option value=\"111\">Macintosh IIvi</option><option value=\"112\">Macintosh IIvx</option><option value=\"113\">PowerBook Duo 210</option><option value=\"114\">PowerBook 180</option><option value=\"115\">Quadra 800</option><option value=\"116\">Centris 610</option><option value=\"117\">Macintosh LC III / III+</option><option value=\"118\">PowerBook 165c</option><option value=\"119\">Macintosh Color Classic</option><option value=\"120\">Centris 650</option><option value=\"121\">Workgroup Server 95</option><option value=\"122\">Workgroup Server 80</option><option value=\"123\">PowerCD</option><option value=\"124\">Apple Design Powered Speakers</option><option value=\"125\">PowerBook 145b</option><option value=\"126\">PowerBook 180c</option><option value=\"127\">Macintosh LC 520</option><option value=\"128\">Workgroup Server 60</option><option value=\"129\">Quadra 840AV</option><option value=\"130\">Centris / Quadra 660AV</option><option value=\"131\">Newton Message Pad</option><option value=\"132\">PowerBook 165</option><option value=\"133\">Macintosh Color Classic II</option><option value=\"134\">Quadra 650</option><option value=\"135\">Quadra 610</option><option value=\"136\">PowerBook Duo 270c</option><option value=\"137\">Quadra 605</option><option value=\"138\">Macintosh TV</option><option value=\"139\">PowerBook Duo 250</option><option value=\"140\">Macintosh LC 550</option><option value=\"141\">Macintosh LC 575</option><option value=\"142\">Apple QuickTake 100</option><option value=\"143\">Power Macintosh 7100</option><option value=\"144\">Power Macintosh 8100</option><option value=\"145\">Power Macintosh 6100</option><option value=\"146\">Workgroup Server 9150</option><option value=\"147\">Workgroup Server 8150</option><option value=\"148\">Workgroup Server 6150</option><option value=\"149\">PowerBook 540/c</option><option value=\"150\">PowerBook 550</option><option value=\"151\">PowerBook Duo 280</option><option value=\"152\">PowerBook 520/c</option><option value=\"153\">PowerBook Duo 280c</option><option value=\"154\">Quadra 630</option><option value=\"155\">PowerBook 150</option><option value=\"156\">Pippin</option><option value=\"157\">Power Macintosh 6200 / 6300</option><option value=\"158\">Power Macintosh/Performa 5200</option><option value=\"159\">Macintosh LC 580</option><option value=\"160\">Power Macintosh 9500</option><option value=\"161\">Power Macintosh 8500</option><option value=\"162\">Power Macintosh 7500</option><option value=\"163\">Power Macintosh 7200</option><option value=\"164\">PowerBook Duo 2300c</option><option value=\"165\">PowerBook 190</option><option value=\"166\">PowerBook 5300</option><option value=\"167\">Power Macintosh/Performa 5300</option><option value=\"168\">Apple Network Server 700/150</option><option value=\"169\">Apple Network Server 500</option><option value=\"170\">Workgroup Server 8550</option><option value=\"171\">Workgroup Server 7250</option><option value=\"172\">Performa 5260 / 5300</option><option value=\"173\">Power Macintosh 7600</option><option value=\"174\">Performa 5400</option><option value=\"175\">Apple Network Server 700/200</option><option value=\"176\">Performa 6360</option><option value=\"177\">Performa 6400</option><option value=\"178\">Power Macintosh 4400</option><option value=\"179\">PowerBook 1400</option><option value=\"180\">Power Macintosh 6500</option><option value=\"181\">Power Macintosh 7300</option><option value=\"182\">PowerBook 3400</option><option value=\"183\">Power Macintosh 8600</option><option value=\"184\">Power Macintosh 5500</option><option value=\"185\">Power Macintosh 9600</option><option value=\"186\">eMate 300</option><option value=\"187\">Twentieth Anniversary Macintosh</option><option value=\"188\">Workgroup Server 7350</option><option value=\"189\">Workgroup Server 9650</option><option value=\"190\">PowerBook 2400c</option><option value=\"191\">PowerBook G3</option><option value=\"192\">Power Macintosh G3 desktop</option><option value=\"193\">Power Macintosh G3 minitower</option><option value=\"194\">Power Macintosh G3 AIO</option><option value=\"195\">Macintosh Server G3</option><option value=\"196\">PowerBook G3 series</option><option value=\"197\">iMac G3</option><option value=\"198\">Macintosh Server G3 (Blue & White)</option><option value=\"199\">Power Macintosh G3 (Blue & White)</option><option value=\"200\">PowerBook G3 (\"Lombard\")</option><option value=\"201\">iBook</option><option value=\"202\">AirPort (802.11b, \"Graphite\")</option><option value=\"203\">Macintosh Server G4</option><option value=\"204\">iMac (slot loading)</option><option value=\"205\">Power Macintosh G4 Graphite</option><option value=\"206\">PowerBook (\"Pismo\")</option><option value=\"207\">Cinema Display (22\")</option><option value=\"208\">Power Macintosh G4 Cube</option><option value=\"209\">iBook (FireWire)</option><option value=\"210\">PowerBook G4 Titanium</option><option value=\"211\">iBook (white)</option><option value=\"212\">Power Macintosh G4 Quicksilver</option><option value=\"213\">Server G4 Quicksilver</option><option value=\"214\">iPod (st gen)</option><option value=\"215\">iMac G4 15\"</option><option value=\"216\">iBook (14\")</option><option value=\"217\">eMac</option><option value=\"218\">Xserve</option><option value=\"219\">iPod (2nd gen)</option><option value=\"220\">iMac G4 17\"</option><option value=\"221\">Power Macintosh G4 MDD</option><option value=\"222\">Macintosh Server G4 MDD</option><option value=\"223\">PowerBook G4 Aluminum (17\")</option><option value=\"224\">PowerBook G4 Aluminum (12\")</option><option value=\"225\">Xserve slot loading</option><option value=\"226\">Xserve Cluster Node</option><option value=\"227\">Power Macintosh G5</option><option value=\"228\">PowerBook G4 Aluminum (15\")</option><option value=\"229\">iBook G4 (12\" / 14\")</option><option value=\"230\">iMac G4 20\"</option><option value=\"231\">Xserve Cluster Node G5</option><option value=\"232\">iPod Mini (1st gen)</option><option value=\"233\">Xserve G5</option><option value=\"234\">iPod+HP</option><option value=\"235\">AirPort Express (802.11g)</option><option value=\"236\">Power Macintosh G5 FX</option><option value=\"237\">Cinema Display (23\")</option><option value=\"238\">Cinema Display (20\")</option><option value=\"239\">Cinema Display (30\")</option><option value=\"240\">iMac G5 20\"</option><option value=\"241\">iMac G5 17\"</option><option value=\"242\">iPod Photo</option><option value=\"243\">iPod Shuffle (1st gen)</option><option value=\"244\">Mac Mini</option><option value=\"245\">iPod Mini (2nd gen)</option><option value=\"246\">iPod (5th gen)</option><option value=\"247\">Power Macintosh G5 dual core</option><option value=\"248\">iMac (Early 2006)</option><option value=\"249\">iPod Radio Remote</option><option value=\"250\">MacBook Pro (15\")</option><option value=\"251\">Mac Mini Core Solo</option><option value=\"252\">Mac Mini Core Duo</option><option value=\"253\">Apple Remote Desktop 3</option><option value=\"254\">MacBook Pro (17\")</option><option value=\"255\">MacBook</option><option value=\"256\">Shake 4</option><option value=\"257\">Nike+iPod</option><option value=\"258\">Xserve (Intel)</option><option value=\"259\">Mac Pro</option><option value=\"260\">iMac (Mid 2006)</option><option value=\"261\">Apple TV (1st gen)</option><option value=\"262\">iPhone (1st generation)</option><option value=\"263\">Apple Keyboard with Numeric Keypad</option><option value=\"264\">Apple Wireless Keyboard (Aluminum)</option><option value=\"265\">Mac Mini (Mid 2007)</option><option value=\"266\">iMac (Mid 2007)</option><option value=\"267\">Apple Mighty Mouse (revised)</option><option value=\"268\">iPod Nano (3rd gen)</option><option value=\"269\">iPod Classic (6th gen)</option><option value=\"270\">iPod Touch (1st gen) (8 & 16 GB)</option><option value=\"271\">Logic Studio</option><option value=\"272\">Mac OS X Leopard (10.5)</option><option value=\"273\">Mac OS X Server (10.5)</option><option value=\"274\">Final Cut Express 4</option><option value=\"275\">Xserve (Early 2008)</option><option value=\"276\">Mac Pro (Early 2008)</option><option value=\"277\">MacBook Air External SuperDrive</option><option value=\"278\">MacBook Air (Early 2008)</option><option value=\"279\">Aperture 2</option><option value=\"280\">Xsan 2</option><option value=\"281\">MacBook Pro (Early 2008) (17\")</option><option value=\"282\">MacBook Pro (Early 2008) (15\")</option><option value=\"283\">MacBook (Early 2008)</option><option value=\"284\">iPod Touch (1st gen) (32 GB)</option><option value=\"285\">Time Capsule (1st gen)</option><option value=\"286\">AirPort Express 802.11n (1st gen)</option><option value=\"287\">Final Cut Studio 2</option><option value=\"288\">iMac (Early 2008)</option><option value=\"289\">Logic Express 8</option><option value=\"290\">MobileMe</option><option value=\"291\">iPhone 3G (8 GB)</option><option value=\"292\">iPhone 3G (16 GB)</option><option value=\"293\">iPod Touch (2nd gen) (8 GB)</option><option value=\"294\">In-Ear Headphones</option><option value=\"295\">iPod Nano (4th gen)</option><option value=\"296\">iPod Classic (6th gen) (120 GB)</option><option value=\"297\">iPod Touch (2nd gen) (16 & 32 GB)</option><option value=\"298\">Final Cut Server</option><option value=\"299\">Bento 2.0</option><option value=\"300\">MacBook (Late 2008) (Aluminum)</option><option value=\"301\">MacBook (Late 2008) (White)</option><option value=\"302\">MacBook Pro (Late 2008) (15\")</option><option value=\"303\">MacBook Air (Late 2008)</option><option value=\"304\">LED Cinema Display</option><option value=\"305\">MacBook Pro (Early 2009) (17\")</option><option value=\"306\">FileMaker Pro 10</option><option value=\"307\">iWork '09</option><option value=\"308\">iLife '09</option><option value=\"309\">MacBook (Early 2009) (White)</option><option value=\"310\">Mac Mini (Early 2009)</option><option value=\"311\">Time Capsule (2nd gen) (500 GB)</option><option value=\"312\">AirPort Extreme 802.11n (3rd gen)</option><option value=\"313\">Time Capsule (2nd gen) (1 TB)</option><option value=\"314\">Mac Pro (Early 2009)</option><option value=\"315\">Apple Keyboard (short)</option><option value=\"316\">iMac (Early 2009)</option><option value=\"317\">iPod Shuffle (3rd gen) (4 GB)</option><option value=\"318\">Xserve (2009)</option><option value=\"319\">MacBook (Mid 2009)</option><option value=\"320\">MacBook Pro (Mid 2009)</option><option value=\"321\">MacBook Air (Mid 2009)</option><option value=\"322\">iPhone 3GS (16 & 32 GB)</option><option value=\"323\">Final Cut Studio 3</option><option value=\"324\">Final Cut Server 1.5</option><option value=\"325\">Logic Studio 2</option><option value=\"326\">Logic Express 9</option><option value=\"327\">Time Capsule (2nd gen) (2 TB)</option><option value=\"328\">Mac OS X Server (10.6)</option><option value=\"329\">Mac OS X Snow Leopard (10.6)</option><option value=\"330\">iPod Touch (3rd gen)</option><option value=\"331\">iPod Shuffle (3rd gen) (2 GB)</option><option value=\"332\">iPod Classic (6th gen) (160 GB)</option><option value=\"333\">iPod Nano (5th gen)</option><option value=\"334\">Mac Mini (Late 2009)</option><option value=\"335\">AirPort Extreme 802.11n (4th gen)</option><option value=\"336\">MacBook (Late 2009)</option><option value=\"337\">iMac (Late 2009)</option><option value=\"338\">Magic Mouse</option><option value=\"339\">Aperture 3</option><option value=\"340\">Time Capsule (3rd gen)</option><option value=\"341\">iPad (Wi-Fi)</option><option value=\"342\">MacBook Pro (Mid 2010)</option><option value=\"343\">iPad (Wi-Fi + 3G)</option><option value=\"344\">MacBook (Mid 2010)</option><option value=\"345\">Mac Mini (Mid 2010)</option><option value=\"346\">iPhone 3GS (8 GB)</option><option value=\"347\">iPhone 4 (GSM) (16 & 32 GB)</option><option value=\"348\">Magic Trackpad</option><option value=\"349\">Mac Pro (Mid 2010)</option><option value=\"350\">iPod Touch (4th gen) (32 GB)</option><option value=\"351\">Apple TV (2nd gen)</option><option value=\"352\">iPod Shuffle (4th gen)</option><option value=\"353\">iPod Touch (4th gen) (8 & 64 GB)</option><option value=\"354\">iPod Nano (6th gen)</option><option value=\"355\">MacBook Air (Late 2010)</option><option value=\"356\">iLife '11</option><option value=\"357\">iPhone 4 (CDMA) (16 & 32 GB)</option><option value=\"358\">MacBook Pro (Early 2011)</option><option value=\"359\">iPad 2 (32 & 64 GB)</option><option value=\"360\">iPad 2 (16 GB)</option><option value=\"361\">iMac (Mid 2011)</option><option value=\"362\">AirPort Extreme 802.11n (5th gen)</option><option value=\"363\">Time Capsule (4th gen)</option><option value=\"364\">Mac Mini (Mid 2011)</option><option value=\"365\">Mac OS X Lion (10.7)</option><option value=\"366\">Thunderbolt Display</option><option value=\"367\">MacBook Air (Mid 2011)</option><option value=\"368\">iOS 5</option><option value=\"369\">AirPort Utility</option><option value=\"370\">Find My Friends</option><option value=\"371\">Cards</option><option value=\"372\">iCloud</option><option value=\"373\">iPhone 4S (16 GB)</option><option value=\"374\">iPhone 4S (32 & 64 GB)</option><option value=\"375\">iPhone 4 (8 GB)</option><option value=\"376\">iPhone Micro USB Adapter</option><option value=\"377\">MacBook Pro (Late 2011)</option><option value=\"378\">iBooks Author</option><option value=\"379\">iPad (3rd gen)</option><option value=\"380\">Apple TV (3rd gen)</option><option value=\"381\">Mac Pro (Mid 2012)</option><option value=\"382\">MacBook Pro (Mid 2012)</option><option value=\"383\">Retina MacBook Pro (3rd gen) (15\")</option><option value=\"384\">AirPort Express 802.11n (2nd gen)</option><option value=\"385\">MacBook Air (Mid 2012)</option><option value=\"386\">OS X Mountain Lion (10.8)</option><option value=\"387\">iPod Touch (4th gen) (16 GB)</option><option value=\"388\">Apple EarPods</option><option value=\"389\">iOS 6</option><option value=\"390\">iPhone 5</option><option value=\"391\">iPod Touch (5th gen)</option><option value=\"392\">iPod Nano (7th gen)</option><option value=\"393\">Retina MacBook Pro (3rd gen) (13\")</option><option value=\"394\">Mac Mini (Late 2012)</option><option value=\"395\">iPad (4th gen) (Wi-Fi)</option><option value=\"396\">iPad Mini (Wi-Fi)</option><option value=\"397\">iPad Mini (Wi-Fi + Cellular)</option><option value=\"398\">iPad (4th gen) (Wi-Fi + Cellular)</option><option value=\"399\">iMac (21.5\") (Late 2012)</option><option value=\"400\">iMac (27\") (Late 2012)</option><option value=\"401\">Retina MacBook Pro</option></select><p>Families</p><select id='families'><option value=\"0\">---Select a Family of Products---</option><option value=\"1\">Compact</option><option value=\"2\">iPad</option><option value=\"3\">AirPort Express</option><option value=\"4\">Newton</option><option value=\"5\">Networking</option><option value=\"6\">iBook</option><option value=\"7\">PowerCD</option><option value=\"8\">iPod Nano</option><option value=\"9\">Mac Mini</option><option value=\"10\">Mac Pro</option><option value=\"11\">PowerBook 500</option><option value=\"12\">QuickTake</option><option value=\"13\">Printers</option><option value=\"14\">Performa</option><option value=\"15\">Apple II</option><option value=\"16\">AirPort, drives</option><option value=\"17\">Apple TV</option><option value=\"18\">LC</option><option value=\"19\">PowerBook G4</option><option value=\"20\">Quadra</option><option value=\"21\">Drives</option><option value=\"22\">MacBook</option><option value=\"23\">iPod Touch</option><option value=\"24\">eMac</option><option value=\"25\">Centris</option><option value=\"26\">Apple III</option><option value=\"27\">iMac</option><option value=\"28\">Software</option><option value=\"29\">Apple Keyboard</option><option value=\"30\">Mac II</option><option value=\"31\">Workgroup Server</option><option value=\"32\">AirPort</option><option value=\"33\">MacBook Air</option><option value=\"34\">Network Server</option><option value=\"35\">Xserve</option><option value=\"36\">PowerBook</option><option value=\"37\">Apple I</option><option value=\"38\">iPod Mini</option><option value=\"39\">iPhone</option><option value=\"40\">Pippin</option><option value=\"41\">iPod Classic</option><option value=\"42\">Portable</option><option value=\"43\">Trackpad</option><option value=\"44\">MacBook Pro</option><option value=\"45\">Scanner</option><option value=\"46\">68000</option><option value=\"47\">Power Macintosh</option><option value=\"48\">Modems</option><option value=\"49\">iPod Accessories</option><option value=\"50\">iPod Shuffle</option><option value=\"51\">Apple Mouse</option><option value=\"52\">Centris / Quadra</option><option value=\"53\">Displays</option><option value=\"54\">PowerBook G3</option><option value=\"55\">Macintosh Server</option><option value=\"56\">PowerBook Duo</option></select><p>Time Range</p><input type='text' id='timeRanges'/><script></script>"
],
"output_type": "pyout",
"prompt_number": 8,
"text": [
"<IPython.core.display.HTML at 0x8646390>"
]
}
],
"prompt_number": 8
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<button id=\"compute\">Compute</button>\n",
"<div id=\"display\">\n",
"</div>\n",
"<script>\n",
" $(\"button#compute\").click(function() {\n",
" var kernel = IPython.notebook.kernel;\n",
" \n",
" var singleProduct = $(\"select#singleProducts\").find(':selected').text();\n",
" kernel.execute(\"singleProduct = '\" +singleProduct+ \"'\");\n",
" \n",
" var family = $(\"select#families\").find(':selected').text();\n",
" kernel.execute(\"family = '\" +family+ \"'\");\n",
" \n",
" var timeRange = $(\"#timeRanges\").val();\n",
" kernel.execute(\"timeRange = '\"+timeRange+\"'\");\n",
" \n",
" var display = \"<p></p>\";\n",
" display += \"<p>singleProduct:\"+singleProduct+\"</p>\";\n",
" display += \"<p>family:\"+family+\"</p>\";\n",
" $(\"div#display\").html(display);\n",
" });\n",
"</script>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"argument = \"\"\n",
"if qtype == 'singleProduct':\n",
" print 'Single Product'\n",
" print singleProduct\n",
" \n",
" qtype = 'product'\n",
" argument = singleProduct\n",
" \n",
"elif qtype == 'family':\n",
" print 'Family'\n",
" print family\n",
" \n",
" qtype = 'family'\n",
" argument = family\n",
" \n",
"elif qtype == 'timeRange':\n",
" print 'Time Range'\n",
" print timeRange\n",
" \n",
" qtype = 'timerange'\n",
" argument = timeRange"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Family\n",
"Mac Pro\n"
]
}
],
"prompt_number": 7
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Setup"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import pandas \n",
"timelineDataFrame = pandas.DataFrame({'Product Name': productName, 'Release Date':releaseDate, \n",
" 'Family': family, 'Date Discontinued': discontinueDate, \n",
" 'Individual Stock Difference': 0, 'Range Stock Difference': 0, \n",
" 'Stock Slope Change': 0}).set_index('Product Name')\n",
"\n",
"def removeOldItems(borderDate):\n",
" criterion = timelineDataFrame['Release Date'].map(lambda date: date.numericDate() > borderDate.numericDate())\n",
" return timelineDataFrame[criterion]\n",
"\n",
"earliestDate = Date(\"9-2-1985\")\n",
"timelineDataFrame = removeOldItems(earliestDate)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 8
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"timeline = getProductReleasesForApple()\n",
"sortedTimeline = sorted(timeline.items(),key=lambda tup: tup[1][0].numericDate())\n",
"productName = []\n",
"family = []\n",
"releaseDate = []\n",
"discontinueDate = []\n",
"for item in sortedTimeline:\n",
" productName.append(item[0])\n",
" releaseDate.append(item[1][0])\n",
" family.append(item[1][1])\n",
" discontinueDate.append(item[1][2])\n",
"\n",
"import pandas \n",
"timelineDataFrame = pandas.DataFrame({'Product Name': productName, 'Release Date':releaseDate, \n",
" 'Family': family, 'Date Discontinued': discontinueDate, \n",
" 'Individual Stock Difference': 0, 'Range Stock Difference': 0, \n",
" 'Stock Slope Change': 0}).set_index('Product Name')\n",
"\n",
"def removeOldItems(borderDate):\n",
" criterion = timelineDataFrame['Release Date'].map(lambda date: date.numericDate() > borderDate.numericDate())\n",
" return timelineDataFrame[criterion]\n",
"\n",
"earliestDate = Date(\"9-2-1985\")\n",
"timelineDataFrame = removeOldItems(earliestDate)\n",
"\n",
"# print timelineDataFrame[:20]\n",
"\n",
"# sampleQuery = Query(\"timerange\", (Date(\"1-1-1911\"), Date(\"3-6-1992\")))\n",
"# sampleQuery.plotSlopeChanges()\n",
"\n",
"print qtype\n",
"print argument\n",
"sampleFamilyQuery = Query(qtype, argument)\n",
"sampleFamilyQuery.plotIndividualStockDifferences()\n",
"sampleFamilyQuery.plotSlopeChanges()"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"family\n",
"Mac Pro\n"
]
}
],
"prompt_number": 9
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Future Direction"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If we were to continue this proect beyond the course, we would like to extend this kind of analysis to more than just Apple Inc. We chose Apple because of the well organized timeline of products page that made collection of data for Apple products easy and throrough. In order for us to have a more generalized means of getting company product information for numerous companies, we would have to change our approach and look at sources of information with broader scopes. We considered press releases and review sites as potential viable candidates because of timely releases and a somewhat uniform page format that would make aquiring product data systematic, instead of having to look at products on a company by company basis.\n",
"\n",
"Aside from increasing the scope of companies we looked at, we would also like to increase the quality of our stock analysis. As computer science majors with no formal background in financial analysis, we chose this project because we were interested in the idea, not because we were particularly adept at this kind of analysis. As a result, we utilized very simple analysis methods to gauge the success of a particular product or product family that left many questions unanswered. We would like to use more advanced and comprehensive methods of analysis after doing a bit more research to get a more accurate picture of product's success."
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Who did what"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Eddie Lee was in charge of data aquisition. This included scraping product data from the \"Timeline of Apple Inc. products\" Wikipedia page and accessing the Yahoo! Finance API so that we could get closing prices for days we were looking into. He also implmented the dropdown menus in this Python notebooks so that the creation of a query could be fast and easy.\n",
"\n",
"Eugene Kim focused on data analysis. He organized all data that was scraped into a DataFrame, added stock data for products in the DataFrame, and implemented interactive plots from matplotlib."
]
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment