{ "metadata": { "name": "Notes 2014-06-23" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": "#HyperText Markup Language\n\n

Mother said there'd be\n nights like these.

\n \n
Howdy there
\n\n " }, { "cell_type": "code", "collapsed": false, "input": "import urllib\n\nhtml_str = urllib.urlopen(\"http://static.decontextualize.com/kittens.html\").read()", "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": "print type(html_str)", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "\n" } ], "prompt_number": 3 }, { "cell_type": "code", "collapsed": false, "input": "print html_str[:10]", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "\n" } ], "prompt_number": 7 }, { "cell_type": "code", "collapsed": false, "input": "h1_tag = document.find(\"h1\")\nprint type(h1_tag)", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "\n" } ], "prompt_number": 8 }, { "cell_type": "code", "collapsed": false, "input": "h1_tag.string", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 9, "text": "u'Kittens and the TV Shows They Love'" } ], "prompt_number": 9 }, { "cell_type": "code", "collapsed": false, "input": "img_tag = document.find('img')\nimg_tag['src']", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 12, "text": "'http://placekitten.com/100/100'" } ], "prompt_number": 12 }, { "cell_type": "code", "collapsed": false, "input": "h1_tag = document.find('h1')\nh1_tag.string", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 27, "text": "u'Kittens and the TV Shows They Love'" } ], "prompt_number": 27 }, { "cell_type": "code", "collapsed": false, "input": "img_tag = document.find('img')\nimg_tag['src']\nprint img_tag.string", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "None\n" } ], "prompt_number": 29 }, { "cell_type": "code", "collapsed": false, "input": "print img_tag", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "\n" } ], "prompt_number": 21 }, { "cell_type": "code", "collapsed": false, "input": "h2_tags = document.find_all(\"h2\")\nprint h2_tags[0].string\nprint h2_tags[1].string\n[tag.string for tag in h2_tags]", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "Fluffy\nMonsieur Whiskeurs\n" }, { "metadata": {}, "output_type": "pyout", "prompt_number": 36, "text": "[u'Fluffy', u'Monsieur Whiskeurs']" } ], "prompt_number": 36 }, { "cell_type": "code", "collapsed": false, "input": "img_tags = document.find_all(\"img\")\n[tag['src'] for tag in img_tags]", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 37, "text": "['http://placekitten.com/100/100', 'http://placekitten.com/150/100']" } ], "prompt_number": 37 }, { "cell_type": "code", "collapsed": false, "input": "spans = document.find_all(\"span\", attrs={\"class\": \"lastcheckup\"})\n", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 39, "text": "[2014-01-17,\n 2013-11-02]" } ], "prompt_number": 39 }, { "cell_type": "code", "collapsed": false, "input": "imgs = document.find_all(\"img\", attrs={'src': 'http://placekitten.com/100/100'})\nprint imgs", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "[]\n" } ], "prompt_number": 41 }, { "cell_type": "markdown", "metadata": {}, "source": "##Finding tags inside other tags\n\nyou can also call find() and find_all() on a tag." }, { "cell_type": "code", "collapsed": false, "input": "kitten_tags = document.find_all(\"div\", attrs={'class': 'kitten'})", "language": "python", "metadata": {}, "outputs": [], "prompt_number": 42 }, { "cell_type": "code", "collapsed": false, "input": "for kitten_tag in kitten_tags:\n h2_tag = kitten_tag.find('h2')\n print h2_tag.string", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "Fluffy\nMonsieur Whiskeurs\n" } ], "prompt_number": 43 }, { "cell_type": "code", "collapsed": false, "input": "for kitten_tag in kitten_tags:\n h2_tag = kitten_tag.find('h2')\n kitten_name = h2_tag.string\n a_tags = kitten_tag.find_all('a')\n a_tag_strings = [tag.string for tag in a_tags]\n a_joined = ', '.join(a_tag_strings)\n print h2_tag.string + \": \" + a_joined\n ", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "Fluffy: Deep Space Nine, Mr. Belvedere\nMonsieur Whiskeurs: The X-Files, Fresh Prince\n" } ], "prompt_number": 46 }, { "cell_type": "code", "collapsed": false, "input": "foo = [\"a\", \"b\", \"c\"]\n\"!\".join(foo)", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 48, "text": "'a!b!c'" } ], "prompt_number": 48 }, { "cell_type": "code", "collapsed": false, "input": "kitten_shows = {}\nfor kitten_tag in kitten_tags:\n h2_tag = kitten_tag.find('h2')\n kitten_name = h2_tag.string\n a_tags = kitten_tag.find_all('a')\n a_tag_strings = [tag.string for tag in a_tags]\n kitten_shows[kitten_name] = a_tag_strings\nkitten_shows\n", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 74, "text": "{u'Fluffy': [u'Deep Space Nine', u'Mr. Belvedere'],\n u'Monsieur Whiskeurs': [u'The X-Files', u'Fresh Prince']}" } ], "prompt_number": 74 }, { "cell_type": "code", "collapsed": false, "input": "import urllib\nfrom bs4 import BeautifulSoup\n\nhtml_str = urllib.urlopen(\"http://static.decontextualize.com/kittens.html\").read()\n\ndocument = BeautifulSoup(html_str)\n\nattrs_we_are_looking_for = {'class': 'kitten'}\nkitten_divs = document.find_all(\"div\", attrs=attrs_we_are_looking_for)\n\nkittens_list = []\nfor kitten_div in kitten_divs:\n kitten_dict = {}\n \n # add name!\n h2_tag = kitten_div.find(\"h2\")\n # does the same thing\n #h2_tags = kitten_div.find_all(\"h2\")[0]\n kitten_dict[\"name\"] = h2_tag.string\n\n # add last checkup!\n span_tag = kitten_div.find(\"span\")\n kitten_dict[\"lastcheckup\"] = span_tag.string\n \n # add image url\n img_tag = kitten_div.find(\"img\")\n kitten_dict[\"img\"] = img_tag['src']\n \n kittens_list.append(kitten_dict)\n \nkittens_list\n", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 88, "text": "[{'img': 'http://placekitten.com/100/100',\n 'lastcheckup': u'2014-01-17',\n 'name': u'Fluffy'},\n {'img': 'http://placekitten.com/150/100',\n 'lastcheckup': u'2013-11-02',\n 'name': u'Monsieur Whiskeurs'}]" } ], "prompt_number": 88 }, { "cell_type": "code", "collapsed": false, "input": "[\n {'name': 'Fluffy',\n 'img': 'http://placekitten.com/100/100',\n 'lastcheckup': '2014-01-17'},\n {'name': 'Monsieur Whiskeurs',\n 'img': 'http://placekitten.com/120/100',\n 'lastcheckup': '2013-11-02'}\n]", "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": "##A real world example.\n\nend up with a data structure that looks like this:\n\n [\n {'name': 'Doe, Joe', 'title': 'Reverse Karate Instructor', 'img_src': 'http://placekitten.com/100/100'},\n {'name': 'Robertson, Bob', 'title': 'Adjunct Person', 'img_src': None}\n ...\n ]\n \n" }, { "cell_type": "code", "collapsed": false, "input": "import urllib\nhtml_str = urllib.urlopen(\"http://www.journalism.columbia.edu/page/10/10?category_ids%5B%5D=2&category_ids%5B%5D=3&category_ids%5B%5D=37\").read()\n", "language": "python", "metadata": {}, "outputs": [], "prompt_number": 68 }, { "cell_type": "code", "collapsed": false, "input": "document = BeautifulSoup(html_str)\nfaculty_list = []\n\nexperts = document.find('ul', attrs={'class': 'experts-list'})\nfaculty_list = experts.find_all('li')\nall_faculty = []\nfor faculty_li in faculty_list:\n faculty_dict = {}\n # get title\n title_tag = faculty_li.find('p', attrs={'class': 'description'})\n if title_tag is None:\n continue\n faculty_dict['title'] = title_tag.string\n\n # get faculty member name\n h4_tag = faculty_li.find('h4')\n a_tag = h4_tag.find('a')\n \n faculty_dict['name'] = a_tag.string\n all_faculty.append(faculty_dict)\n \nfaculty_list", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 69, "text": "[
  • ,\n
  • \n
    \n

    Adkison, Abbey

    \n

    Digital Media Coordinator

    \n
    \n
  • ,\n
  • ,\n
  • \n\"Dolores-barclay\"\n
    \n

    Barclay, Dolores

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n
    \n

    Baum, Geraldine

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Ebell_112811\"\n
    \n

    Bell, Emily

    \n

    Professor of Professional Practice & Director, Tow Center for Digital Journalism

    \n

    Expertise: DIGITAL MEDIA, TRENDS IN JOURNALISM, DATA

    \n
    \n
  • ,\n
  • \n\"Hbenedict_112811\"\n
    \n

    Benedict, Helen

    \n

    Professor

    \n

    Expertise: SOCIAL ISSUES, INTERNATIONAL AFFAIRS

    \n
    \n
  • ,\n
  • \n\"Bennet_john\"\n
    \n

    Bennet, John

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Bennett_rob\"\n
    \n

    Bennett, Rob

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Nina-berman\"\n
    \n

    Berman, Nina

    \n

    Associate Professor

    \n

    Expertise: PHOTOJOURNALISM

    \n
    \n
  • ,\n
  • \n
    \n

    Blair, Gwenda

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Blum_david\"\n
    \n

    Blum, David

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Georgebodarky\"\n
    \n

    Bodarky, George

    \n

    Adjunct Assistant Professor

    \n
    \n
  • ,\n
  • \n\"Walt-bogdanich\"\n
    \n

    Bogdanich, Walt

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Lennart-bourin\"\n
    \n

    Bourin, Lennart

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Curtisbrainard\"\n
    \n

    Brainard, Curtis

    \n

    Staff Writer

    \n
    \n
  • ,\n
  • \n\"Bruder\"\n
    \n

    Bruder, Jessica

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Burford\"\n
    \n

    Burford, Melanie

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Burleigh_nina\"\n
    \n

    Burleigh, Nina

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • ,\n
  • \n\"Heathercabot\"\n
    \n

    Cabot, Heather

    \n

    Adjunct Professor

    \n
    \n
  • ,\n
  • \n\"Elena\"\n
    \n

    Cabral, Elena

    \n

    Adjunct Faculty & Assistant Director, Student Services

    \n
    \n
  • ,\n
  • \n\"Canipe_chris\"\n\n
  • ,\n
  • \n\"Charnas_dan\"\n
    \n

    Charnas, Dan

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Cohen_julie\"\n
    \n

    Cohen, Julie

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Lisa-cohen\"\n
    \n

    Cohen, Lisa R.

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Cohen_sarah\"\n
    \n

    Cohen, Sarah

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Coll-web\"\n
    \n

    Coll, Steve

    \n

    Dean & Henry R. Luce Professor of Journalism

    \n
    \n
  • ,\n
  • \n\"Anncooper2\"\n
    \n

    Cooper, Ann

    \n

    CBS Professor of Professional Practice in International Journalism

    \n

    Expertise: INTERNATIONAL AFFAIRS, BROADCAST

    \n
    \n
  • ,\n
  • \n\"Coronel_sheila\"\n
    \n

    Coronel, Sheila

    \n

    Dean of Academic Affairs

    \n

    Expertise: INTERNATIONAL AFFAIRS, INVESTIGATIVE REPORTING

    \n
    \n
  • ,\n
  • \n\"Unknown-1\"\n
    \n

    Coyne , Kevin

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Hockenberry_-alison-craiglow\"\n\n
  • ,\n
  • \n\"Jcross_112811\"\n
    \n

    Cross, June

    \n

    Professor

    \n

    Expertise: BROADCAST

    \n
    \n
  • ,\n
  • \n\"Brent-cunningham\"\n
    \n

    Cunningham, Brent

    \n

    Deputy Editor

    \n
    \n
  • ,\n
  • ,\n
  • \n\"Adepalma\"\n
    \n

    DePalma, Anthony

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Brucedesilva\"\n
    \n

    DeSilva, Bruce

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Deitsch_\"\n
    \n

    Deitsch, Richard

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Jdinges_112811\"\n
    \n

    Dinges, John

    \n

    Godfrey Lowell Cabot Professor of Journalism

    \n

    Expertise: BROADCAST

    \n
    \n
  • ,\n
  • \n\"Sdodd_horiz\"\n
    \n

    Dodd, Scott

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Donahue\"\n
    \n

    Donahue, Kerry

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n
    \n

    Drew, Christopher

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • ,\n
  • \n\"Edsall\"\n
    \n

    Edsall, Thomas B.

    \n

    \n

    Expertise: Politics, SOCIAL ISSUES

    \n
    \n
  • ,\n
  • \n\"Epstein\"\n
    \n

    Epstein, Randi Hutter

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n
    \n

    Evans, Farrell

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Tysonevans\"\n
    \n

    Evans , Tyson

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • ,\n
  • \n\"Fishman\"\n
    \n

    Fishman, Elizabeth Weinreb

    \n

    Associate Dean for Communications

    \n
    \n
  • ,\n
  • \n\"Ford\"\n
    \n

    Ford, Constance Mitchell

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Frederick\"\n
    \n

    Frederick, Pamela Platt

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Sfreedman_112811\"\n
    \n

    Freedman, Samuel

    \n

    Professor

    \n

    Expertise: RELIGION, ETHICS, EDUCATION

    \n
    \n
  • ,\n
  • \n
    \n

    Freeman, George

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Freeman_john\"\n
    \n

    Freeman, John

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Hfrench\"\n
    \n

    French, Howard

    \n

    Associate Professor

    \n

    Expertise: INTERNATIONAL AFFAIRS, PHOTOJOURNALISM

    \n
    \n
  • ,\n
  • \n\"Stephen_fried\"\n
    \n

    Fried, Stephen

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • ,\n
  • \n\"Vanessa\"\n\n
  • ,\n
  • \n
    \n

    Gilderman, Greg

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Siggissler\"\n
    \n

    Gissler, Sig

    \n

    Administrator

    \n
    \n
  • ,\n
  • \n\"Tgitlin\"\n
    \n

    Gitlin, Todd

    \n

    Professor & Chair, Ph.D. Program

    \n

    Expertise: Politics, SOCIAL ISSUES

    \n
    \n
  • ,\n
  • \n
    \n

    Giudice, Barbara

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Martygoldensohn\"\n
    \n

    Goldensohn, Marty

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Agoldman\"\n
    \n

    Goldman, Ari

    \n

    Professor

    \n

    Expertise: RELIGION

    \n
    \n
  • ,\n
  • \n
    \n

    Goldstein, Jacob

    \n

    Adjunct Professor

    \n
    \n
  • ,\n
  • \n\"Wgrueskin\"\n
    \n

    Grueskin, Bill

    \n

    Professor of Professional Practice

    \n

    Expertise: TRENDS IN JOURNALISM, DIGITAL MEDIA

    \n
    \n
  • ,\n
  • ,\n
  • \n\"Ahaburchak\"\n
    \n

    Haburchak, Alan

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Hajdu_david\"\n
    \n

    Hajdu, David

    \n

    Associate Professor

    \n

    Expertise: ARTS/CULTURE

    \n
    \n
  • ,\n
  • \n
    \n

    Hall, Stephen

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Lynnell-faculty\"\n
    \n

    Hancock, LynNell

    \n

    H. Gordon Garbedian Professor of Journalism & Director, Spencer Fellowship Program

    \n

    Expertise: EDUCATION

    \n
    \n
  • ,\n
  • \n\"Hansen\"\n
    \n

    Hansen, Mark

    \n

    Director, David and Helen Gurley Brown Institute for Media Innovation & Professor of Journalism

    \n

    Expertise: TRENDS IN JOURNALISM, DIGITAL MEDIA, DATA

    \n
    \n
  • ,\n
  • \n
    \n

    Harris, Mark

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Julie\"\n
    \n

    Hartenstein, Julie

    \n

    Associate Dean

    \n
    \n
  • ,\n
  • \n\"Larryheinzerling\"\n
    \n

    Heinzerling, Larry

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Tomherman\"\n
    \n

    Herman, Tom

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n
    \n

    Hickey, Neil

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Lars-head-shot-v2\"\n\n
  • ,\n
  • \n\"Hogan\"\n
    \n

    Hogan, Pamela

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Marguerite_holloway2\"\n
    \n

    Holloway, Marguerite

    \n

    Associate Professor & Director, Science and Environmental Journalism

    \n

    Expertise: SCIENCE/ENVIRONMENT

    \n
    \n
  • ,\n
  • \n\"Hoyt_-mike\"\n
    \n

    Hoyt, Michael

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • ,\n
  • \n\"Sisaacs_112811\"\n
    \n

    Isaacs, Stephen

    \n

    Professor Emeritus of Journalism

    \n
    \n
  • ,\n
  • ,\n
  • \n\"Rjohn\"\n
    \n

    John, Richard R.

    \n

    Professor

    \n

    Expertise: HISTORY OF COMMUNICATIONS

    \n
    \n
  • ,\n
  • \n
    \n

    Jones, Matthew L.

    \n

    Instructor, The Lede Program

    \n
    \n
  • ,\n
  • ,\n
  • \n
    \n

    Kalita, S. Mitra

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n
    \n

    Kann, Peter R.

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Kantrowitz\"\n
    \n

    Kantrowitz, Barbara

    \n

    Adjunct Faculty & Associate Director, Continuing Education

    \n
    \n
  • ,\n
  • \n\"Karle_-stuart\"\n
    \n

    Karle, Stuart

    \n

    Adjunct Faculty; William J. Brennan Jr. Visiting Professor of First Amendment Issues

    \n
    \n
  • ,\n
  • \n\"Rickkarr\"\n
    \n

    Karr, Rick

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Thomaskent\"\n
    \n

    Kent, Thomas

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Dklatell\"\n
    \n

    Klatell, David

    \n

    Professor of Professional Practice & Chair, International Studies

    \n

    Expertise: ETHICS, INTERNATIONAL AFFAIRS

    \n
    \n
  • ,\n
  • \n
    \n

    Klein, Adam

    \n

    Adjunct Professor

    \n
    \n
  • ,\n
  • \n\"Kim-kleman-1\"\n
    \n

    Kleman, Kim

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Knee\"\n
    \n

    Knee, Jonathan

    \n

    Adjunct Professor

    \n
    \n
  • ,\n
  • \n
    \n

    Konner, Joan

    \n

    Dean Emerita

    \n
    \n
  • ,\n
  • \n\"Mkottler\"\n
    \n

    Kottler, Mark

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • ,\n
  • \n\"Landis\"\n
    \n

    Landis, Peter

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Dlee_new\"\n
    \n

    Lee, Deborah

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Haupt\"\n
    \n

    Lehmann-Haupt, Christopher

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Nlemann_112811\"\n
    \n

    Lemann, Nicholas

    \n

    Joseph Pulitzer II and Edith Pulitzer Moore Professor of Journalism; Dean Emeritus

    \n

    Expertise: ETHICS, TRENDS IN JOURNALISM, HISTORY OF COMMUNICATIONS

    \n
    \n
  • ,\n
  • \n
    \n

    Levenson, Jacob

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Sethlipsky\"\n
    \n

    Lipsky, Seth

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Rlipton_112811\"\n
    \n

    Lipton, Rhoda

    \n

    Senior Lecturer in Discipline

    \n

    Expertise: BROADCAST

    \n
    \n
  • ,\n
  • \n
    \n

    Lombardi, Kristen

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Tamiluhby\"\n
    \n

    Luhby, Tami

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • ,\n
  • \n\"Tony-maciulius\"\n
    \n

    Maciulis, Tony

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Maharidge_-dale\"\n
    \n

    Maharidge, Dale

    \n

    Professor

    \n

    Expertise: SOCIAL ISSUES

    \n
    \n
  • ,\n
  • \n\"Tommason\"\n\n
  • ,\n
  • \n\"Matloff_-judith\"\n
    \n

    Matloff, Judith

    \n

    Adjunct faculty

    \n
    \n
  • ,\n
  • \n
    \n

    Maytal, Itai

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n
    \n

    McCormick, David

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n
    \n

    McCray, Melvin

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Mcdonald_-erica\"\n\n
  • ,\n
  • \n\"Smcgregor_112811\"\n
    \n

    McGregor, Susan E.

    \n

    Assistant Professor & Assistant Director, Tow Center for Digital Journalism

    \n

    Expertise: DIGITAL MEDIA, TRENDS IN JOURNALISM, DATA

    \n
    \n
  • ,\n
  • \n
    \n

    McMasters, Kelly

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n
    \n

    Mencher, Melvin

    \n

    Professor Emeritus

    \n
    \n
  • ,\n
  • \n\"Merchant_-preston\"\n\n
  • ,\n
  • \n
    \n

    Miller , Stephen C.

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Mintz_-jim\"\n
    \n

    Mintz, James

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • ,\n
  • \n\"Snasar_112811\"\n
    \n

    Nasar, Sylvia

    \n

    John S. and James L. Knight Professor of Business Journalism

    \n

    Expertise: BUSINESS/ECONOMICS

    \n
    \n
  • ,\n
  • \n\"Vnavasky_112811\"\n
    \n

    Navasky, Victor

    \n

    George T. Delacorte Professor in Magazine Journalism; Director, Delacorte Center for Magazine Journalism; Chair, Columbia Journalism Review

    \n

    Expertise: SOCIAL ISSUES, Politics

    \n
    \n
  • ,\n
  • \n
    \n

    Newman, Maria

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Nisenholtz\"\n
    \n

    Nisenholtz, Martin

    \n

    Adjunct Professor

    \n
    \n
  • ,\n
  • \n\"Nocera\"\n
    \n

    Nocera, Joseph

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Rnorton\"\n
    \n

    Norton, Rob

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Habibanosheen2\"\n
    \n

    Nosheen, Habiba

    \n

    Adjunct Professor

    \n
    \n
  • ,\n
  • \n\"Amynutt\"\n
    \n

    Nutt, Amy

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • ,\n
  • \n\"Bridget-o_brian-headshot\"\n\n
  • ,\n
  • \n\"Charlesornstein\"\n
    \n

    Ornstein, Charles

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • ,\n
  • \n\"Padawer\"\n
    \n

    Padawer , Ruth

    \n

    Adjunct Professor

    \n
    \n
  • ,\n
  • \n\"Spadwe_112811\"\n
    \n

    Padwe, Sandy

    \n

    Special Lecturer

    \n
    \n
  • ,\n
  • \n
    \n

    Parker, Diantha

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n
    \n

    Parrish, Adam

    \n

    Instructor, The Lede Program

    \n
    \n
  • ,\n
  • \n\"Patel_headshot2\"\n
    \n

    Patel, Samir S.

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Perlman_-merrill\"\n
    \n

    Perlman, Merrill

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Pool-eckert\"\n
    \n

    Pool-Eckert, Marquita

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • ,\n
  • \n
    \n

    Quinn, T.J.

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • ,\n
  • \n
    \n

    Rate, Betsy

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n
    \n

    Richardson, Lynda

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Richmn\"\n
    \n

    Richman, Joe

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Robbins\"\n
    \n

    Robbins, Ed

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n
    \n

    Roberts, Fletcher

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Rubinstein_-julian\"\n
    \n

    Rubinstein, Julian

    \n

    Web Editor

    \n
    \n
  • ,\n
  • ,\n
  • \n\"Sacha\"\n
    \n

    Sacha, Bob

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Richschapiro\"\n
    \n

    Schapiro, Rich

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n
    \n

    Schatz, Robin

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Bjschechter\"\n
    \n

    Schecter, B.J.

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Hilkeschellmann_final\"\n
    \n

    Schellmann, Hilke

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Schoen\"\n
    \n

    Schoen, John

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n
    \n

    Schoonmaker, Mary Ellen

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Mschudson_112811\"\n
    \n

    Schudson, Michael

    \n

    Professor

    \n

    Expertise: TRENDS IN JOURNALISM, HISTORY OF COMMUNICATIONS

    \n
    \n
  • ,\n
  • \n\"Eschumacher_112811\"\n
    \n

    Schumacher-Matos, Ed

    \n

    Adjunct Faculty

    \n

    Expertise: ETHICS, SOCIAL ISSUES, IMMIGRATION

    \n
    \n
  • ,\n
  • \n\n
  • ,\n
  • \n\"Seave\"\n
    \n

    Seave, Ava

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Seidman\"\n
    \n

    Seideman, David

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n
    \n

    Shanor, Donald

    \n

    G. L. Cabot Professor Emeritus

    \n
    \n
  • ,\n
  • \n\"Shapiro_-bruce\"\n
    \n

    Shapiro, Bruce

    \n

    Executive Director

    \n
    \n
  • ,\n
  • \n\"Mshapiro_112811\"\n
    \n

    Shapiro, Michael

    \n

    Professor

    \n

    Expertise: ETHICS, DIGITAL MEDIA

    \n
    \n
  • ,\n
  • \n\"Ahmed-shihab-eldin\"\n
    \n

    Shihab-Eldin, Ahmed

    \n

    Adjunct Assistant Professor

    \n
    \n
  • ,\n
  • \n\"Siegel_-lloyd-2012\"\n
    \n

    Siegel, Lloyd

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Singer\"\n
    \n

    Singer, Amy

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Mariasliwa\"\n
    \n

    Sliwa, Maria

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Solomon_-alisa\"\n
    \n

    Solomon, Alisa

    \n

    Professor & Director, Arts Concentration, M.A. Program

    \n

    Expertise: ARTS/CULTURE, SOCIAL ISSUES

    \n
    \n
  • ,\n
  • \n\"Jonathan-soma\"\n
    \n

    Soma, Jonathan

    \n

    Instructor, The Lede Program

    \n
    \n
  • ,\n
  • \n\"Ernie\"\n
    \n

    Sotomayor, Ernest

    \n

    Dean of Student Affairs

    \n
    \n
  • ,\n
  • \n\"Paulaspan\"\n
    \n

    Span, Paula

    \n

    Adjunct Professor

    \n
    \n
  • ,\n
  • \n\"Ssreenavisan_112811\"\n
    \n

    Sreenivasan , Sree

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Karen-stabiner\"\n
    \n

    Stabiner, Karen

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Jstewart_112811\"\n
    \n

    Stewart, James

    \n

    Bloomberg Professor of Business Journalism

    \n

    Expertise: BUSINESS/ECONOMICS

    \n
    \n
  • ,\n
  • \n\"Stille\"\n
    \n

    Stille, Alexander

    \n

    San Paolo Professor of International Journalism

    \n

    Expertise: Politics, INTERNATIONAL AFFAIRS

    \n
    \n
  • ,\n
  • \n\"Stivers\"\n
    \n

    Stivers, Cyndi

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Subramanian_-sushma\"\n
    \n

    Subramanian, Sushma

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Mike_sullivan\"\n
    \n

    Sullivan, Michael

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Surowicz\"\n\n
  • ,\n
  • ,\n
  • \n\"Tamman_-maurice\"\n
    \n

    Tamman, Maurice

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n
    \n

    Tenen, Dennis

    \n

    Instructor, The Lede Program

    \n
    \n
  • ,\n
  • \n\"Topping\"\n
    \n

    Topping, Seymour

    \n

    San Paolo Professor of International Journalism Emeritus

    \n
    \n
  • ,\n
  • \n\"Dody\"\n
    \n

    Tsiantar, Dody

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Dlinhtu_112811\"\n
    \n

    Tu, Duy Linh

    \n

    Assistant Professor of Professional Practice & Director, Digital Media Program

    \n

    Expertise: DIGITAL MEDIA, TRENDS IN JOURNALISM

    \n
    \n
  • ,\n
  • \n\"Andie_tucher2\"\n
    \n

    Tucher, Andie

    \n

    Associate Professor; Director, Ph.D. Program

    \n

    Expertise: HISTORY OF COMMUNICATIONS

    \n
    \n
  • ,\n
  • ,\n
  • \n\"Mike-ventura\"\n
    \n

    Ventura, Michael

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • ,\n
  • \n\"Wald_-jonathan\"\n
    \n

    Wald, Jonathan

    \n

    Adjunt Faculty

    \n
    \n
  • ,\n
  • \n\"Richard_wald2\"\n
    \n

    Wald, Richard

    \n

    Fred W. Friendly Professor of Professional Practice in Media and Society

    \n

    Expertise: ETHICS, BROADCAST

    \n
    \n
  • ,\n
  • \n\"Wayne\"\n
    \n

    Wayne, Leslie

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Jweiner\"\n
    \n

    Weiner, Jonathan

    \n

    Maxwell M. Geffen Professor of Medical and Scientific Journalism

    \n

    Expertise: SCIENCE/ENVIRONMENT

    \n
    \n
  • ,\n
  • \n\"Weiss\"\n
    \n

    Weiss, Gary

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Welby\"\n
    \n

    Welby, Julianne

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Betsy_west2\"\n
    \n

    West, Betsy

    \n

    Associate Professor of Professional Practice

    \n

    Expertise: BROADCAST

    \n
    \n
  • ,\n
  • \n\"Wheatley_-bill\"\n
    \n

    Wheatley, Jr., William

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Chris-wiggins\"\n
    \n

    Wiggins, Chris

    \n

    Instructor, The Lede Program

    \n
    \n
  • ,\n
  • \n\"Williams_-josh---high-res\"\n
    \n

    Williams, Josh

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n
    \n

    Wilson, Duff

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n
    \n

    Wolk, Joshua

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Woodward\"\n
    \n

    Woodward, Tali

    \n

    Adjunct Faculty & Director, M.A. Program

    \n
    \n
  • ,\n
  • ,\n
  • \n
    \n

    Yu, Frederick T C.

    \n

    CBS Professor Emeritus International Journalism

    \n
    \n
  • ,\n
  • ,\n
  • \n
    \n

    Zucker, John

    \n

    Adjunct Faculty

    \n
    \n
  • ,\n
  • \n\"Zuckerman\"\n
    \n

    Zuckerman, Jocelyn Craugh

    \n

    Adjunct Faculty

    \n
    \n
  • ]" } ], "prompt_number": 69 }, { "cell_type": "code", "collapsed": false, "input": "import pandas as pd\nfaculty_frame = pd.DataFrame(all_faculty)\nfaculty_frame[faculty_frame[\"title\"]==\"Adjunct Faculty\"]", "language": "python", "metadata": {}, "outputs": [ { "html": "
    \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    nametitle
    1 Barclay, Dolores Adjunct Faculty
    2 Baum, Geraldine Adjunct Faculty
    5 Bennet, John Adjunct Faculty
    6 Bennett, Rob Adjunct Faculty
    8 Blair, Gwenda Adjunct Faculty
    9 Blum, David Adjunct Faculty
    11 Bogdanich, Walt Adjunct Faculty
    12 Bourin, Lennart Adjunct Faculty
    14 Bruder, Jessica Adjunct Faculty
    15 Burford, Melanie Adjunct Faculty
    16 Burleigh, Nina Adjunct Faculty
    20 Charnas, Dan Adjunct Faculty
    21 Cohen, Julie Adjunct Faculty
    22 Cohen, Lisa R. Adjunct Faculty
    23 Cohen, Sarah Adjunct Faculty
    27 Coyne , Kevin Adjunct Faculty
    31 DePalma, Anthony Adjunct Faculty
    32 DeSilva, Bruce Adjunct Faculty
    33 Deitsch, Richard Adjunct Faculty
    35 Dodd, Scott Adjunct Faculty
    36 Donahue, Kerry Adjunct Faculty
    37 Drew, Christopher Adjunct Faculty
    40 Evans, Farrell Adjunct Faculty
    41 Evans , Tyson Adjunct Faculty
    43 Ford, Constance Mitchell Adjunct Faculty
    44 Frederick, Pamela Platt Adjunct Faculty
    46 Freeman, George Adjunct Faculty
    47 Freeman, John Adjunct Faculty
    49 Fried, Stephen Adjunct Faculty
    51 Gilderman, Greg Adjunct Faculty
    54 Giudice, Barbara Adjunct Faculty
    55 Goldensohn, Marty Adjunct Faculty
    59 Haburchak, Alan Adjunct Faculty
    61 Hall, Stephen Adjunct Faculty
    64 Harris, Mark Adjunct Faculty
    66 Heinzerling, Larry Adjunct Faculty
    67 Herman, Tom Adjunct Faculty
    68 Hickey, Neil Adjunct Faculty
    70 Hogan, Pamela Adjunct Faculty
    72 Hoyt, Michael Adjunct Faculty
    77 Kann, Peter R. Adjunct Faculty
    80 Karr, Rick Adjunct Faculty
    81 Kent, Thomas Adjunct Faculty
    84 Kleman, Kim Adjunct Faculty
    87 Kottler, Mark Adjunct Faculty
    88 Landis, Peter Adjunct Faculty
    89 Lee, Deborah Adjunct Faculty
    90 Lehmann-Haupt, Christopher Adjunct Faculty
    92 Levenson, Jacob Adjunct Faculty
    93 Lipsky, Seth Adjunct Faculty
    95 Lombardi, Kristen Adjunct Faculty
    96 Luhby, Tami Adjunct Faculty
    97 Maciulis, Tony Adjunct Faculty
    101 Maytal, Itai Adjunct Faculty
    102 McCormick, David Adjunct Faculty
    103 McCray, Melvin Adjunct Faculty
    106 McMasters, Kelly Adjunct Faculty
    109 Miller , Stephen C. Adjunct Faculty
    110 Mintz, James Adjunct Faculty
    113 Newman, Maria Adjunct Faculty
    ......
    \n

    104 rows \u00d7 2 columns

    \n
    ", "metadata": {}, "output_type": "pyout", "prompt_number": 66, "text": " name title\n1 Barclay, Dolores Adjunct Faculty\n2 Baum, Geraldine Adjunct Faculty\n5 Bennet, John Adjunct Faculty\n6 Bennett, Rob Adjunct Faculty\n8 Blair, Gwenda Adjunct Faculty\n9 Blum, David Adjunct Faculty\n11 Bogdanich, Walt Adjunct Faculty\n12 Bourin, Lennart Adjunct Faculty\n14 Bruder, Jessica Adjunct Faculty\n15 Burford, Melanie Adjunct Faculty\n16 Burleigh, Nina Adjunct Faculty\n20 Charnas, Dan Adjunct Faculty\n21 Cohen, Julie Adjunct Faculty\n22 Cohen, Lisa R. Adjunct Faculty\n23 Cohen, Sarah Adjunct Faculty\n27 Coyne , Kevin Adjunct Faculty\n31 DePalma, Anthony Adjunct Faculty\n32 DeSilva, Bruce Adjunct Faculty\n33 Deitsch, Richard Adjunct Faculty\n35 Dodd, Scott Adjunct Faculty\n36 Donahue, Kerry Adjunct Faculty\n37 Drew, Christopher Adjunct Faculty\n40 Evans, Farrell Adjunct Faculty\n41 Evans , Tyson Adjunct Faculty\n43 Ford, Constance Mitchell Adjunct Faculty\n44 Frederick, Pamela Platt Adjunct Faculty\n46 Freeman, George Adjunct Faculty\n47 Freeman, John Adjunct Faculty\n49 Fried, Stephen Adjunct Faculty\n51 Gilderman, Greg Adjunct Faculty\n54 Giudice, Barbara Adjunct Faculty\n55 Goldensohn, Marty Adjunct Faculty\n59 Haburchak, Alan Adjunct Faculty\n61 Hall, Stephen Adjunct Faculty\n64 Harris, Mark Adjunct Faculty\n66 Heinzerling, Larry Adjunct Faculty\n67 Herman, Tom Adjunct Faculty\n68 Hickey, Neil Adjunct Faculty\n70 Hogan, Pamela Adjunct Faculty\n72 Hoyt, Michael Adjunct Faculty\n77 Kann, Peter R. Adjunct Faculty\n80 Karr, Rick Adjunct Faculty\n81 Kent, Thomas Adjunct Faculty\n84 Kleman, Kim Adjunct Faculty\n87 Kottler, Mark Adjunct Faculty\n88 Landis, Peter Adjunct Faculty\n89 Lee, Deborah Adjunct Faculty\n90 Lehmann-Haupt, Christopher Adjunct Faculty\n92 Levenson, Jacob Adjunct Faculty\n93 Lipsky, Seth Adjunct Faculty\n95 Lombardi, Kristen Adjunct Faculty\n96 Luhby, Tami Adjunct Faculty\n97 Maciulis, Tony Adjunct Faculty\n101 Maytal, Itai Adjunct Faculty\n102 McCormick, David Adjunct Faculty\n103 McCray, Melvin Adjunct Faculty\n106 McMasters, Kelly Adjunct Faculty\n109 Miller , Stephen C. Adjunct Faculty\n110 Mintz, James Adjunct Faculty\n113 Newman, Maria Adjunct Faculty\n ... ...\n\n[104 rows x 2 columns]" } ], "prompt_number": 66 }, { "cell_type": "code", "collapsed": false, "input": "cats = [\"Garfield\", \"Heathcliff\", \"Grumpy Cat\", \"Socks\"]\n\ncats_output = []\n\nfor item in cats:\n # create an empty dictionary\n cat_dict = {}\n \n # do some stuff, add stuff to the dictionary\n cat_dict['name'] = item\n cat_dict['name_length'] = len(item)\n \n # append that dictionary to our output list\n cats_output.append(cat_dict)\n\ncats_output\n\n#\n#what we want:\n#[\n# {\"name\": \"Garfield\", \"name_length\": 8},\n# {\"name\": \"Heathcliff\", \"name_length\": 10},\n# ...\n#]", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 70, "text": "[{'name': 'Garfield', 'name_length': 8},\n {'name': 'Heathcliff', 'name_length': 10},\n {'name': 'Grumpy Cat', 'name_length': 10},\n {'name': 'Socks', 'name_length': 5}]" } ], "prompt_number": 70 }, { "cell_type": "code", "collapsed": false, "input": "import pandas as pd\ncats_df = pd.DataFrame(cats_output)\ncats_df", "language": "python", "metadata": {}, "outputs": [ { "html": "
    \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    namename_length
    0 Garfield 8
    1 Heathcliff 10
    2 Grumpy Cat 10
    3 Socks 5
    \n

    4 rows \u00d7 2 columns

    \n
    ", "metadata": {}, "output_type": "pyout", "prompt_number": 72, "text": " name name_length\n0 Garfield 8\n1 Heathcliff 10\n2 Grumpy Cat 10\n3 Socks 5\n\n[4 rows x 2 columns]" } ], "prompt_number": 72 }, { "cell_type": "markdown", "metadata": {}, "source": "##Scraping menupages for fun and profit! whoops I mean for JOURNALISM.\n" }, { "cell_type": "code", "collapsed": false, "input": "import urllib\nfrom bs4 import BeautifulSoup\n\nhtml_str = urllib.urlopen(\"http://www.menupages.com/restaurants/all-areas/morningside-heights/all-cuisines/\").read() \n\ndocument = BeautifulSoup(html_str)\n\ntable_tag = document.find(\"table\")\n\nrestaurant_list = []\n\nfor tr_tag in table_tag.find_all(\"tr\"):\n restaurant_dict = {}\n \n reviews_tag = tr_tag.find(\"td\", attrs={'class': 'reviews'})\n if reviews_tag is None:\n continue\n restaurant_dict['reviews'] = int(reviews_tag.string)\n \n restaurant_list.append(restaurant_dict)\n \nrestaurant_list", "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 93, "text": "[{'reviews': 43},\n {'reviews': 5},\n {'reviews': 38},\n {'reviews': 31},\n {'reviews': 4},\n {'reviews': 19},\n {'reviews': 5},\n {'reviews': 2},\n {'reviews': 34},\n {'reviews': 8},\n {'reviews': 18},\n {'reviews': 1},\n {'reviews': 11},\n {'reviews': 7},\n {'reviews': 2},\n {'reviews': 0},\n {'reviews': 0},\n {'reviews': 37},\n {'reviews': 52},\n {'reviews': 70},\n {'reviews': 0},\n {'reviews': 116},\n {'reviews': 0},\n {'reviews': 0},\n {'reviews': 10},\n {'reviews': 1},\n {'reviews': 18},\n {'reviews': 0},\n {'reviews': 0},\n {'reviews': 0},\n {'reviews': 21},\n {'reviews': 18},\n {'reviews': 48},\n {'reviews': 0},\n {'reviews': 1},\n {'reviews': 1},\n {'reviews': 0},\n {'reviews': 0},\n {'reviews': 46},\n {'reviews': 5},\n {'reviews': 2},\n {'reviews': 39},\n {'reviews': 2},\n {'reviews': 8},\n {'reviews': 0},\n {'reviews': 5},\n {'reviews': 33},\n {'reviews': 11},\n {'reviews': 17},\n {'reviews': 16},\n {'reviews': 35},\n {'reviews': 23},\n {'reviews': 3},\n {'reviews': 14},\n {'reviews': 36},\n {'reviews': 97},\n {'reviews': 2},\n {'reviews': 0},\n {'reviews': 19},\n {'reviews': 14},\n {'reviews': 3},\n {'reviews': 34},\n {'reviews': 1},\n {'reviews': 0},\n {'reviews': 34},\n {'reviews': 1},\n {'reviews': 16},\n {'reviews': 38},\n {'reviews': 3},\n {'reviews': 19},\n {'reviews': 26},\n {'reviews': 52},\n {'reviews': 26},\n {'reviews': 4},\n {'reviews': 12},\n {'reviews': 44},\n {'reviews': 0},\n {'reviews': 68},\n {'reviews': 16},\n {'reviews': 0},\n {'reviews': 1},\n {'reviews': 26},\n {'reviews': 13}]" } ], "prompt_number": 93 }, { "cell_type": "code", "collapsed": false, "input": "[\n {\"name\": \"Ajanta\", \"price\": 2, \"rating\": 3.0, \"reviews\": 43,\n {\"name\": \"Amigos\", \"price\": 3, \"rating\": 3.0, \"reviews\": 5}\n ...\n \n]", "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }