Introduction to APIs

This tutorial introduces Application Programming Interfaces (APIs) using the Yelp API as an example.

Key Terminology

  • API: An Application Programming Interface is the mechanism by which computers can talk to other computers and share information.
  • REST API: This is a type of API that uses standard web protocols to communicate.
  • Endpoint: This is a URL, just like you see in a web browser, for requesting specific kinds of data from the API.
  • Request: A request is how you initiate a conversation with an API in order to "request" information. Requests are made to specific endpoints.
  • Parameters: When you issue a request to an endpoint, that is make a web request, you usually include some parameters, like search terms, to refine your query.
  • Response: When you make an API request
  • JSON: JavaScript Object Notation is the data format many APIs use to communicate over tehe web.
  • Credentials/Authentication/Keys: Many APIs require some form of authentication in order to get information. Because APIs are computers talking to computers it is not a good practice to use usernames and passwords (those are for humans!). Instead, APIs often use a system called OAuth in which the API service gives you an access token or a key instead of a password. Don't share your access tokens!

Start with Documentation

  • Because every API is different, it is important to become familiar with the various endpoints and parameters by reading the documentation.
  • Lets take a look at the Yelp API
  • Before we dive into the Python code, we should play with the Yelp API Console.

Accessing APIs with Python

  • We can use Python to progammatically request data from the API.
  • This is much easier than using a web browser
  • To do this we are going to use a 3rd party library, Requests, to handle the HTTP requests.

In [39]:
import requests

Getting authenticated

  • To access the Yelp API we need to be authenticated. How do I know that? I read the documentation!
  • APIs are the door to the information system and we need the keys to unlock the door.
  • We create an "app" and that app has a set of keys for opening the door.

In [40]:
AUTHENTICATION_URL = "https://api.yelp.com/oauth2/token"
GRANT_TYPE="client_credentials"
APP_ID="4EDvg4OOFwJB-NT-tovQZQ"
APP_SECRET="r9YgAPf97vkyNvMWiEQySBG2ZoAL3TX8s28Po5kpk99y0I8NuoBGBB25nTMnVkrW"

Getting an access token

  • I know it is complicated, but once we have the keys then we must request a temporary access token.
  • This is all part of a machine-to-machine protocol for authorizing access to information system called Oauth

In [41]:
authentication_response = requests.post(AUTHENTICATION_URL, 
                         data={"grant_type": GRANT_TYPE,
                               "client_id": APP_ID,
                               "client_secret":APP_SECRET},
                        headers={"content-type":"application/x-www-form-urlencoded"})
authentication_response.json()


Out[41]:
{'access_token': '4syVgjjcxtyrf0vJAO4IanHdtpNquXN1MZuokIkNQsPsPZ_70Y4mSBk10bX7y5HrbcNJfE4daP1TNVY5d-h2w-MpF88OPNDZEUATIRDMwxjddnj78LCSzeTxNUblWHYx',
 'expires_in': 15485966,
 'token_type': 'Bearer'}

In [42]:
authentication_token = authentication_response.json()['access_token']
authentication_token


Out[42]:
'4syVgjjcxtyrf0vJAO4IanHdtpNquXN1MZuokIkNQsPsPZ_70Y4mSBk10bX7y5HrbcNJfE4daP1TNVY5d-h2w-MpF88OPNDZEUATIRDMwxjddnj78LCSzeTxNUblWHYx'
  • Following the documentation, this means it is working! We now have the access_token needed to make requests to the business search api
  • Now we need to read the documentation of the business search api to learn how to craft an HTTP request to the search endpoint.
    • Usually this means "What is the request URL?" and "What are the parameters?"

In [43]:
# request endpoint
SEARCH_URL = "https://api.yelp.com/v3/businesses/search"

# parameters
SEARCH_LOCATION = "Pittsburgh"
SEARCH_LIMIT = 50
SEARCH_TERM = ""
  • Now we can look at the documentation for the Requests python library about how to make a request
  • I also looked at some example python code provided by Yelp to figured out the authorization headers

In [44]:
# make an HTTP GET request to the 
search_response = requests.get(SEARCH_URL,
                               headers={"Authorization":"Bearer {}".format(authentication_token)},
                               params={"term":SEARCH_TERM,
                                       "location":SEARCH_LOCATION,
                                       "limit":SEARCH_LIMIT})
# print the parsed response
search_response.json()


Out[44]:
{'businesses': [{'categories': [{'alias': 'gardens',
     'title': 'Botanical Gardens'},
    {'alias': 'parks', 'title': 'Parks'}],
   'coordinates': {'latitude': 40.439248, 'longitude': -79.947347},
   'display_phone': '(412) 622-6914',
   'distance': 2753.5113774459996,
   'id': 'phipps-conservatory-and-botanical-gardens-pittsburgh',
   'image_url': 'https://s3-media3.fl.yelpcdn.com/bphoto/gVY6b6FGf29TPpyRfec_eA/o.jpg',
   'is_closed': False,
   'location': {'address1': '1 Schenley Park',
    'address2': None,
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['1 Schenley Park', 'Pittsburgh, PA 15213'],
    'state': 'PA',
    'zip_code': '15213'},
   'name': 'Phipps Conservatory and Botanical Gardens',
   'phone': '+14126226914',
   'rating': 4.5,
   'review_count': 208,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/phipps-conservatory-and-botanical-gardens-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'bakeries', 'title': 'Bakeries'},
    {'alias': 'french', 'title': 'French'}],
   'coordinates': {'latitude': 40.47312, 'longitude': -79.95886},
   'display_phone': '(412) 682-2210',
   'distance': 3594.3372926879997,
   'id': 'la-gourmandine-bakery-and-pastry-shop-pittsburgh',
   'image_url': 'https://s3-media2.fl.yelpcdn.com/bphoto/BIN_lwo-4Y441qdDljtdlw/o.jpg',
   'is_closed': False,
   'location': {'address1': '4605 Butler St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['4605 Butler St', 'Pittsburgh, PA 15201'],
    'state': 'PA',
    'zip_code': '15201'},
   'name': 'La Gourmandine Bakery & Pastry Shop',
   'phone': '+14126822210',
   'price': '$',
   'rating': 4.5,
   'review_count': 319,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/la-gourmandine-bakery-and-pastry-shop-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'cafes', 'title': 'Cafes'},
    {'alias': 'vegan', 'title': 'Vegan'},
    {'alias': 'gluten_free', 'title': 'Gluten-Free'}],
   'coordinates': {'latitude': 40.42868, 'longitude': -79.98312},
   'display_phone': '(412) 432-5950',
   'distance': 1810.823413442,
   'id': 'amazing-cafe-pittsburgh',
   'image_url': 'https://s3-media1.fl.yelpcdn.com/bphoto/MRs4DuFdoUOT3i9myDVjjw/o.jpg',
   'is_closed': False,
   'location': {'address1': 'Amazing Yoga',
    'address2': '1506 E Carson St',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['Amazing Yoga',
     '1506 E Carson St',
     'Pittsburgh, PA 15203'],
    'state': 'PA',
    'zip_code': '15203'},
   'name': 'Amazing Cafe',
   'phone': '+14124325950',
   'price': '$$',
   'rating': 4.5,
   'review_count': 92,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/amazing-cafe-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'localflavor', 'title': 'Local Flavor'},
    {'alias': 'galleries', 'title': 'Art Galleries'}],
   'coordinates': {'latitude': 40.4580766, 'longitude': -80.0098045},
   'display_phone': '(412) 342-8152',
   'distance': 2995.32694343,
   'id': 'randyland-pittsburgh',
   'image_url': 'https://s3-media1.fl.yelpcdn.com/bphoto/qKb3Ic3CCP9ThesbVO4ilA/o.jpg',
   'is_closed': False,
   'location': {'address1': '1501 Arch St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['1501 Arch St', 'Pittsburgh, PA 15212'],
    'state': 'PA',
    'zip_code': '15212'},
   'name': 'Randyland',
   'phone': '+14123428152',
   'price': '$',
   'rating': 5.0,
   'review_count': 34,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/randyland-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'coffee', 'title': 'Coffee & Tea'}],
   'coordinates': {'latitude': 40.46608, 'longitude': -79.96509},
   'display_phone': '(412) 918-1864',
   'distance': 2658.04468491,
   'id': 'espresso-a-mano-pittsburgh',
   'image_url': 'https://s3-media4.fl.yelpcdn.com/bphoto/Dgp7oGwzhm5OsT7DAoby9w/o.jpg',
   'is_closed': False,
   'location': {'address1': '3623 Butler St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['3623 Butler St', 'Pittsburgh, PA 15201'],
    'state': 'PA',
    'zip_code': '15201'},
   'name': 'Espresso A Mano',
   'phone': '+14129181864',
   'price': '$',
   'rating': 4.5,
   'review_count': 265,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/espresso-a-mano-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'mexican', 'title': 'Mexican'}],
   'coordinates': {'latitude': 40.4389190673828,
    'longitude': -79.9553070068359},
   'display_phone': '(412) 682-1115',
   'distance': 2112.44141009,
   'id': 'las-palmas-pittsburgh',
   'image_url': 'https://s3-media1.fl.yelpcdn.com/bphoto/sJwjDQx97bOqUvQ6XU0CLA/o.jpg',
   'is_closed': False,
   'location': {'address1': '326 Atwood St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['326 Atwood St', 'Pittsburgh, PA 15213'],
    'state': 'PA',
    'zip_code': '15213'},
   'name': 'Las Palmas',
   'phone': '+14126821115',
   'price': '$',
   'rating': 4.5,
   'review_count': 156,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/las-palmas-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'vietnamese', 'title': 'Vietnamese'},
    {'alias': 'cafes', 'title': 'Cafes'},
    {'alias': 'bubbletea', 'title': 'Bubble Tea'}],
   'coordinates': {'latitude': 40.472145273083,
    'longitude': -79.9589364429569},
   'display_phone': '(412) 251-5030',
   'distance': 3498.311515436,
   'id': 'banh-mi-and-ti-pittsburgh',
   'image_url': 'https://s3-media2.fl.yelpcdn.com/bphoto/xM6YDddW2KoyL1-LGMaOoQ/o.jpg',
   'is_closed': False,
   'location': {'address1': '4502 Butler St',
    'address2': '',
    'address3': None,
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['4502 Butler St', 'Pittsburgh, PA 15201'],
    'state': 'PA',
    'zip_code': '15201'},
   'name': 'Banh Mi & Ti',
   'phone': '+14122515030',
   'price': '$',
   'rating': 5.0,
   'review_count': 88,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/banh-mi-and-ti-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'desserts', 'title': 'Desserts'},
    {'alias': 'coffee', 'title': 'Coffee & Tea'}],
   'coordinates': {'latitude': 40.426, 'longitude': -79.96665},
   'display_phone': '(412) 586-7306',
   'distance': 2331.0359701479997,
   'id': 'big-dog-coffee-pittsburgh',
   'image_url': 'https://s3-media1.fl.yelpcdn.com/bphoto/c1aMTjbw65PNZtoe15h5yw/o.jpg',
   'is_closed': False,
   'location': {'address1': '2717 Sarah St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['2717 Sarah St', 'Pittsburgh, PA 15203'],
    'state': 'PA',
    'zip_code': '15203'},
   'name': 'Big Dog Coffee',
   'phone': '+14125867306',
   'price': '$',
   'rating': 4.5,
   'review_count': 196,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/big-dog-coffee-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'localflavor', 'title': 'Local Flavor'}],
   'coordinates': {'latitude': 40.4331554340253,
    'longitude': -80.017204284668},
   'display_phone': '',
   'distance': 3470.2455914399998,
   'id': 'mount-washington-pittsburgh',
   'image_url': 'https://s3-media2.fl.yelpcdn.com/bphoto/9OAjjMrrJIpq4K1Kcx-WnQ/o.jpg',
   'is_closed': False,
   'location': {'address1': '',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['Pittsburgh, PA 15211'],
    'state': 'PA',
    'zip_code': '15211'},
   'name': 'Mount Washington',
   'phone': '',
   'rating': 5.0,
   'review_count': 58,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/mount-washington-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'streetvendors', 'title': 'Street Vendors'},
    {'alias': 'mexican', 'title': 'Mexican'}],
   'coordinates': {'latitude': 40.455585, 'longitude': -79.977913},
   'display_phone': '(412) 849-8864',
   'distance': 1217.2588132496,
   'id': 'edgar-tacos-stand-pittsburgh',
   'image_url': 'https://s3-media2.fl.yelpcdn.com/bphoto/gQ1mbNiSwD_f_6a6HG2ciQ/o.jpg',
   'is_closed': False,
   'location': {'address1': '2627 Penn Ave',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['2627 Penn Ave', 'Pittsburgh, PA 15222'],
    'state': 'PA',
    'zip_code': '15222'},
   'name': 'Edgar Tacos Stand',
   'phone': '+14128498864',
   'price': '$',
   'rating': 5.0,
   'review_count': 39,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/edgar-tacos-stand-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'coffee', 'title': 'Coffee & Tea'},
    {'alias': 'gourmet', 'title': 'Specialty Food'}],
   'coordinates': {'latitude': 40.4502105712891,
    'longitude': -79.9857177734375},
   'display_phone': '(412) 471-0133',
   'distance': 832.1744252699999,
   'id': 'prestogeorge-fine-foods-pittsburgh-3',
   'image_url': 'https://s3-media1.fl.yelpcdn.com/bphoto/Zts-5SCG_ZE_DZQIvnlDBw/o.jpg',
   'is_closed': False,
   'location': {'address1': '1719 Penn Ave',
    'address2': None,
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['1719 Penn Ave', 'Pittsburgh, PA 15222'],
    'state': 'PA',
    'zip_code': '15222'},
   'name': 'Prestogeorge Fine Foods',
   'phone': '+14124710133',
   'price': '$$',
   'rating': 4.5,
   'review_count': 62,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/prestogeorge-fine-foods-pittsburgh-3?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'newamerican', 'title': 'American (New)'},
    {'alias': 'mexican', 'title': 'Mexican'}],
   'coordinates': {'latitude': 40.4422285652929,
    'longitude': -80.0019846968895},
   'display_phone': '(412) 471-8256',
   'distance': 1955.8901257119999,
   'id': 'täkō-pittsburgh',
   'image_url': 'https://s3-media2.fl.yelpcdn.com/bphoto/qpVuEMaaS8CNLwTzNoryiA/o.jpg',
   'is_closed': False,
   'location': {'address1': '214 6th St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['214 6th St', 'Pittsburgh, PA 15222'],
    'state': 'PA',
    'zip_code': '15222'},
   'name': 'täkō',
   'phone': '+14124718256',
   'price': '$$',
   'rating': 4.5,
   'review_count': 577,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/t%C3%A4k%C5%8D-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'tradamerican', 'title': 'American (Traditional)'},
    {'alias': 'bars', 'title': 'Bars'}],
   'coordinates': {'latitude': 40.4521777, 'longitude': -79.9837408},
   'display_phone': '(412) 281-0949',
   'distance': 922.3436533280001,
   'id': 'smallman-galley-pittsburgh-2',
   'image_url': 'https://s3-media4.fl.yelpcdn.com/bphoto/jNAwwPsgK35E6EbkCypd2Q/o.jpg',
   'is_closed': False,
   'location': {'address1': '54 21st St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['54 21st St', 'Pittsburgh, PA 15222'],
    'state': 'PA',
    'zip_code': '15222'},
   'name': 'Smallman Galley',
   'phone': '+14122810949',
   'price': '$$',
   'rating': 4.5,
   'review_count': 208,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/smallman-galley-pittsburgh-2?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'yelpevents', 'title': 'Yelp Events'}],
   'coordinates': {'latitude': 40.44504, 'longitude': -79.95643},
   'display_phone': '',
   'distance': 1917.94060104,
   'id': 'yelps-swingin-to-summer-pittsburgh',
   'image_url': 'https://s3-media2.fl.yelpcdn.com/bphoto/-sDXfppJp1F5KlEyrxL6WQ/o.jpg',
   'is_closed': False,
   'location': {'address1': '4141 Fifth Ave',
    'address2': '',
    'address3': None,
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['4141 Fifth Ave', 'Pittsburgh, PA 15213'],
    'state': 'PA',
    'zip_code': '15213'},
   'name': "Yelp's Swingin' to Summer",
   'phone': '',
   'rating': 5.0,
   'review_count': 43,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/yelps-swingin-to-summer-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'mexican', 'title': 'Mexican'}],
   'coordinates': {'latitude': 40.42859, 'longitude': -79.9855199},
   'display_phone': '(412) 238-8518',
   'distance': 1870.354509382,
   'id': 'doce-taqueria-pittsburgh',
   'image_url': 'https://s3-media3.fl.yelpcdn.com/bphoto/A9Q89uQ7ygtI9SvM74p2SQ/o.jpg',
   'is_closed': False,
   'location': {'address1': '1220 E Carson St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['1220 E Carson St', 'Pittsburgh, PA 15203'],
    'state': 'PA',
    'zip_code': '15203'},
   'name': 'Doce Taqueria',
   'phone': '+14122388518',
   'price': '$',
   'rating': 4.5,
   'review_count': 145,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/doce-taqueria-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'french', 'title': 'French'}],
   'coordinates': {'latitude': 40.42893, 'longitude': -79.98715},
   'display_phone': '(412) 488-9695',
   'distance': 1880.8120007019998,
   'id': 'cafe-du-jour-pittsburgh',
   'image_url': 'https://s3-media4.fl.yelpcdn.com/bphoto/NtaFibKZTTCQHPeUscKBSg/o.jpg',
   'is_closed': False,
   'location': {'address1': '1107 E Carson St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['1107 E Carson St', 'Pittsburgh, PA 15203'],
    'state': 'PA',
    'zip_code': '15203'},
   'name': 'Cafe Du Jour',
   'phone': '+14124889695',
   'price': '$$',
   'rating': 4.5,
   'review_count': 136,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/cafe-du-jour-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'newamerican', 'title': 'American (New)'}],
   'coordinates': {'latitude': 40.438556, 'longitude': -80.019299},
   'display_phone': '(412) 904-4442',
   'distance': 3469.9364372259997,
   'id': 'altius-pittsburgh',
   'image_url': 'https://s3-media2.fl.yelpcdn.com/bphoto/N2QHbmOhiI1TiCZb9DdLJQ/o.jpg',
   'is_closed': False,
   'location': {'address1': '1230 Grandview Ave',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['1230 Grandview Ave', 'Pittsburgh, PA 15211'],
    'state': 'PA',
    'zip_code': '15211'},
   'name': 'Altius',
   'phone': '+14129044442',
   'price': '$$$',
   'rating': 4.5,
   'review_count': 308,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/altius-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'italian', 'title': 'Italian'}],
   'coordinates': {'latitude': 40.4275054931641,
    'longitude': -79.9823684692383},
   'display_phone': '(412) 390-2012',
   'distance': 1928.8852395779998,
   'id': 'dish-osteria-and-bar-pittsburgh',
   'image_url': 'https://s3-media2.fl.yelpcdn.com/bphoto/aa23vUV19agCfMakKf8O6g/o.jpg',
   'is_closed': False,
   'location': {'address1': '128 S 17th St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['128 S 17th St', 'Pittsburgh, PA 15203'],
    'state': 'PA',
    'zip_code': '15203'},
   'name': 'Dish Osteria and Bar',
   'phone': '+14123902012',
   'price': '$$$',
   'rating': 4.5,
   'review_count': 182,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/dish-osteria-and-bar-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'grocery', 'title': 'Grocery'},
    {'alias': 'delis', 'title': 'Delis'}],
   'coordinates': {'latitude': 40.4618721008301,
    'longitude': -79.9485549926758},
   'display_phone': '(412) 681-1227',
   'distance': 3215.4329956159995,
   'id': 'groceria-italiana-pittsburgh',
   'image_url': 'https://s3-media1.fl.yelpcdn.com/bphoto/3Wa2prg71eQ7wc5wsg4TmA/o.jpg',
   'is_closed': False,
   'location': {'address1': '237 Cedarville St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['237 Cedarville St', 'Pittsburgh, PA 15224'],
    'state': 'PA',
    'zip_code': '15224'},
   'name': 'Groceria Italiana',
   'phone': '+14126811227',
   'price': '$',
   'rating': 4.5,
   'review_count': 34,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/groceria-italiana-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'coffee', 'title': 'Coffee & Tea'},
    {'alias': 'vegan', 'title': 'Vegan'},
    {'alias': 'mideastern', 'title': 'Middle Eastern'}],
   'coordinates': {'latitude': 40.4804344177246,
    'longitude': -79.9541091918945},
   'display_phone': '(412) 781-5204',
   'distance': 4503.464885001999,
   'id': 'b52-cafe-pittsburgh-4',
   'image_url': 'https://s3-media2.fl.yelpcdn.com/bphoto/zdtWTsq6WKv7JqifAkvGYA/o.jpg',
   'is_closed': False,
   'location': {'address1': '5202 Butler St',
    'address2': None,
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['5202 Butler St', 'Pittsburgh, PA 15201'],
    'state': 'PA',
    'zip_code': '15201'},
   'name': 'B52 Cafe',
   'phone': '+14127815204',
   'price': '$$',
   'rating': 4.5,
   'review_count': 89,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/b52-cafe-pittsburgh-4?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'newamerican', 'title': 'American (New)'}],
   'coordinates': {'latitude': 40.442334, 'longitude': -80.002066},
   'display_phone': '(412) 391-2752',
   'distance': 1961.3683190719998,
   'id': 'butcher-and-the-rye-pittsburgh',
   'image_url': 'https://s3-media1.fl.yelpcdn.com/bphoto/63sIj4GEaO6AAP699oOzmw/o.jpg',
   'is_closed': False,
   'location': {'address1': '212 6th St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['212 6th St', 'Pittsburgh, PA 15222'],
    'state': 'PA',
    'zip_code': '15222'},
   'name': 'Butcher and the Rye',
   'phone': '+14123912752',
   'price': '$$$',
   'rating': 4.5,
   'review_count': 570,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/butcher-and-the-rye-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'coffee', 'title': 'Coffee & Tea'},
    {'alias': 'breakfast_brunch', 'title': 'Breakfast & Brunch'}],
   'coordinates': {'latitude': 40.4407077, 'longitude': -79.9586246},
   'display_phone': '(412) 708-4270',
   'distance': 1787.5420572659998,
   'id': 'redhawk-coffee-pittsburgh',
   'image_url': 'https://s3-media1.fl.yelpcdn.com/bphoto/vyDSxPXJACjTKvpYCOmPlw/o.jpg',
   'is_closed': False,
   'location': {'address1': '120 Meyran Ave',
    'address2': '',
    'address3': None,
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['120 Meyran Ave', 'Pittsburgh, PA 15213'],
    'state': 'PA',
    'zip_code': '15213'},
   'name': 'Redhawk Coffee',
   'phone': '+14127084270',
   'price': '$',
   'rating': 5.0,
   'review_count': 41,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/redhawk-coffee-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'newamerican', 'title': 'American (New)'}],
   'coordinates': {'latitude': 40.4459691792727,
    'longitude': -79.9935398250818},
   'display_phone': '(412) 201-5656',
   'distance': 1227.8265765464,
   'id': 'eleven-pittsburgh',
   'image_url': 'https://s3-media1.fl.yelpcdn.com/bphoto/J-EIRLBPVURT7ciK15SlXw/o.jpg',
   'is_closed': False,
   'location': {'address1': '1150 Smallman St',
    'address2': None,
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['1150 Smallman St', 'Pittsburgh, PA 15222'],
    'state': 'PA',
    'zip_code': '15222'},
   'name': 'Eleven',
   'phone': '+14122015656',
   'price': '$$$',
   'rating': 4.0,
   'review_count': 518,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/eleven-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'french', 'title': 'French'},
    {'alias': 'tradamerican', 'title': 'American (Traditional)'},
    {'alias': 'soulfood', 'title': 'Soul Food'}],
   'coordinates': {'latitude': 40.45039, 'longitude': -79.95086},
   'display_phone': '(412) 621-2700',
   'distance': 2472.036041172,
   'id': 'legume-pittsburgh',
   'image_url': 'https://s3-media4.fl.yelpcdn.com/bphoto/413Y-xESrK_j6fZFeukLaQ/o.jpg',
   'is_closed': False,
   'location': {'address1': '214 N Craig St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['214 N Craig St', 'Pittsburgh, PA 15213'],
    'state': 'PA',
    'zip_code': '15213'},
   'name': 'Legume',
   'phone': '+14126212700',
   'price': '$$$',
   'rating': 4.5,
   'review_count': 311,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/legume-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'winetastingroom', 'title': 'Wine Tasting Room'},
    {'alias': 'wine_bars', 'title': 'Wine Bars'}],
   'coordinates': {'latitude': 40.457335, 'longitude': -79.975468},
   'display_phone': '(412) 566-1000',
   'distance': 1440.843067604,
   'id': 'pittsburgh-winery-pittsburgh',
   'image_url': 'https://s3-media3.fl.yelpcdn.com/bphoto/793Talcs3oARfBXy3oj4QA/o.jpg',
   'is_closed': False,
   'location': {'address1': '2815 Penn Ave',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['2815 Penn Ave', 'Pittsburgh, PA 15222'],
    'state': 'PA',
    'zip_code': '15222'},
   'name': 'Pittsburgh Winery',
   'phone': '+14125661000',
   'price': '$$',
   'rating': 4.5,
   'review_count': 64,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/pittsburgh-winery-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'diners', 'title': 'Diners'},
    {'alias': 'breakfast_brunch', 'title': 'Breakfast & Brunch'}],
   'coordinates': {'latitude': 40.45199, 'longitude': -79.98366},
   'display_phone': '(412) 281-6366',
   'distance': 898.602830582,
   'id': 'p-and-gs-pamelas-diner-pittsburgh-3',
   'image_url': 'https://s3-media4.fl.yelpcdn.com/bphoto/TrPg9hOnGzJoQmV0JyXAOw/o.jpg',
   'is_closed': False,
   'location': {'address1': '60 21 St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['60 21 St', 'Pittsburgh, PA 15222'],
    'state': 'PA',
    'zip_code': '15222'},
   'name': "P&G's Pamela's Diner",
   'phone': '+14122816366',
   'price': '$',
   'rating': 4.5,
   'review_count': 365,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/p-and-gs-pamelas-diner-pittsburgh-3?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'bakeries', 'title': 'Bakeries'},
    {'alias': 'british', 'title': 'British'},
    {'alias': 'seafood', 'title': 'Seafood'}],
   'coordinates': {'latitude': 40.42843, 'longitude': -79.97939},
   'display_phone': '(412) 381-2447',
   'distance': 1802.46723736,
   'id': 'the-pub-chip-shop-pittsburgh',
   'image_url': 'https://s3-media1.fl.yelpcdn.com/bphoto/WgIunH6SKGuaBc-oQM3t2Q/o.jpg',
   'is_closed': False,
   'location': {'address1': '1830 E Carson St',
    'address2': None,
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['1830 E Carson St', 'Pittsburgh, PA 15203'],
    'state': 'PA',
    'zip_code': '15203'},
   'name': 'The Pub Chip Shop',
   'phone': '+14123812447',
   'price': '$',
   'rating': 4.5,
   'review_count': 173,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/the-pub-chip-shop-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'british', 'title': 'British'},
    {'alias': 'irish', 'title': 'Irish'},
    {'alias': 'pubs', 'title': 'Pubs'}],
   'coordinates': {'latitude': 40.4284324645996,
    'longitude': -79.9794692993164},
   'display_phone': '(412) 381-3977',
   'distance': 1806.7825216359997,
   'id': 'pipers-pub-pittsburgh',
   'image_url': 'https://s3-media3.fl.yelpcdn.com/bphoto/1kjBBbNjwOJ_0ii8U9P3Hg/o.jpg',
   'is_closed': False,
   'location': {'address1': '1828 E Carson St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['1828 E Carson St', 'Pittsburgh, PA 15203'],
    'state': 'PA',
    'zip_code': '15203'},
   'name': "Piper's Pub",
   'phone': '+14123813977',
   'price': '$$',
   'rating': 4.5,
   'review_count': 297,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/pipers-pub-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'argentine', 'title': 'Argentine'}],
   'coordinates': {'latitude': 40.449043, 'longitude': -79.987573},
   'display_phone': '(412) 709-6622',
   'distance': 866.227255,
   'id': 'gaucho-parrilla-argentina-pittsburgh',
   'image_url': 'https://s3-media2.fl.yelpcdn.com/bphoto/Nlu_0MVtSiIFC9CC_NVlsA/o.jpg',
   'is_closed': False,
   'location': {'address1': '1601 Penn Ave',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['1601 Penn Ave', 'Pittsburgh, PA 15222'],
    'state': 'PA',
    'zip_code': '15222'},
   'name': 'Gaucho Parrilla Argentina',
   'phone': '+14127096622',
   'price': '$$',
   'rating': 4.5,
   'review_count': 977,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/gaucho-parrilla-argentina-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'landmarks',
     'title': 'Landmarks & Historical Buildings'}],
   'coordinates': {'latitude': 40.4322731314699,
    'longitude': -80.0041576149602},
   'display_phone': '(412) 442-2000',
   'distance': 2529.924966576,
   'id': 'monongahela-incline-pittsburgh',
   'image_url': 'https://s3-media1.fl.yelpcdn.com/bphoto/wUYbRcFL82rlAhXzzN_jNA/o.jpg',
   'is_closed': False,
   'location': {'address1': '5 Grandview Ave',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['5 Grandview Ave', 'Pittsburgh, PA 15211'],
    'state': 'PA',
    'zip_code': '15211'},
   'name': 'Monongahela Incline',
   'phone': '+14124422000',
   'rating': 4.5,
   'review_count': 97,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/monongahela-incline-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'cafes', 'title': 'Cafes'},
    {'alias': 'coffee', 'title': 'Coffee & Tea'}],
   'coordinates': {'latitude': 40.461502, 'longitude': -79.923988},
   'display_phone': '(412) 737-0862',
   'distance': 5024.289956512,
   'id': 'zekes-coffee-pittsburgh',
   'image_url': 'https://s3-media2.fl.yelpcdn.com/bphoto/Od--IPDqML9zITgzmbYs5A/o.jpg',
   'is_closed': False,
   'location': {'address1': '6015 Penn Ave',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['6015 Penn Ave', 'Pittsburgh, PA 15206'],
    'state': 'PA',
    'zip_code': '15206'},
   'name': "Zeke's Coffee",
   'phone': '+14127370862',
   'price': '$',
   'rating': 4.5,
   'review_count': 73,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/zekes-coffee-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'vegan', 'title': 'Vegan'},
    {'alias': 'bars', 'title': 'Bars'},
    {'alias': 'modern_european', 'title': 'Modern European'}],
   'coordinates': {'latitude': 40.4656499, 'longitude': -79.94933},
   'display_phone': '',
   'distance': 3431.80328686,
   'id': 'apteka-pittsburgh',
   'image_url': 'https://s3-media3.fl.yelpcdn.com/bphoto/FcLTUhiRPCLMnk6PBSG3jA/o.jpg',
   'is_closed': False,
   'location': {'address1': '4606 Penn Ave',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['4606 Penn Ave', 'Pittsburgh, PA 15224'],
    'state': 'PA',
    'zip_code': '15224'},
   'name': 'Apteka',
   'phone': '',
   'price': '$$',
   'rating': 4.5,
   'review_count': 91,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/apteka-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'mexican', 'title': 'Mexican'}],
   'coordinates': {'latitude': 40.3945960998535,
    'longitude': -80.0216827392578},
   'display_phone': '(412) 388-5018',
   'distance': 6635.128573919999,
   'id': 'las-palmas-carniceria-pittsburgh',
   'image_url': 'https://s3-media4.fl.yelpcdn.com/bphoto/w-3LKB2je3ZrBS8ib7K6ug/o.jpg',
   'is_closed': False,
   'location': {'address1': '700 Brookline Blvd',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['700 Brookline Blvd', 'Pittsburgh, PA 15226'],
    'state': 'PA',
    'zip_code': '15226'},
   'name': 'Las Palmas Carniceria',
   'phone': '+14123885018',
   'price': '$',
   'rating': 4.5,
   'review_count': 181,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/las-palmas-carniceria-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'italian', 'title': 'Italian'}],
   'coordinates': {'latitude': 40.42161, 'longitude': -79.99346},
   'display_phone': '(412) 488-1440',
   'distance': 2836.6091655439996,
   'id': 'alla-famiglia-pittsburgh',
   'image_url': 'https://s3-media4.fl.yelpcdn.com/bphoto/XZWySlNHTmPgw4SbumUOPg/o.jpg',
   'is_closed': False,
   'location': {'address1': '804 E Warrington Ave',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['804 E Warrington Ave', 'Pittsburgh, PA 15210'],
    'state': 'PA',
    'zip_code': '15210'},
   'name': 'Alla Famiglia',
   'phone': '+14124881440',
   'price': '$$$$',
   'rating': 4.5,
   'review_count': 135,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/alla-famiglia-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'polish', 'title': 'Polish'}],
   'coordinates': {'latitude': 40.4523578, 'longitude': -79.9820206},
   'display_phone': '(412) 281-2906',
   'distance': 889.35025212,
   'id': 's-and-d-polish-deli-pittsburgh',
   'image_url': 'https://s3-media4.fl.yelpcdn.com/bphoto/YhUMbbCcnOIzvZcxKgQOtQ/o.jpg',
   'is_closed': False,
   'location': {'address1': '2204 Penn Ave',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['2204 Penn Ave', 'Pittsburgh, PA 15222'],
    'state': 'PA',
    'zip_code': '15222'},
   'name': 'S&D Polish Deli',
   'phone': '+14122812906',
   'price': '$',
   'rating': 4.5,
   'review_count': 138,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/s-and-d-polish-deli-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'mediterranean', 'title': 'Mediterranean'}],
   'coordinates': {'latitude': 40.4389554, 'longitude': -79.9993319},
   'display_phone': '(412) 281-4693',
   'distance': 1826.506431742,
   'id': 'madonnas-mediterranean-cuisine-pittsburgh',
   'image_url': 'https://s3-media3.fl.yelpcdn.com/bphoto/QfsSb-S6AZg6iDOR2l9wTg/o.jpg',
   'is_closed': False,
   'location': {'address1': '408 Smithfield St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['408 Smithfield St', 'Pittsburgh, PA 15219'],
    'state': 'PA',
    'zip_code': '15219'},
   'name': "Madonna's Mediterranean Cuisine",
   'phone': '+14122814693',
   'price': '$',
   'rating': 4.5,
   'review_count': 58,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/madonnas-mediterranean-cuisine-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'bars', 'title': 'Bars'},
    {'alias': 'mexican', 'title': 'Mexican'}],
   'coordinates': {'latitude': 40.44404, 'longitude': -79.99654},
   'display_phone': '(412) 586-5024',
   'distance': 1482.011594144,
   'id': 'bakersfield-penn-ave-pittsburgh',
   'image_url': 'https://s3-media1.fl.yelpcdn.com/bphoto/29_Oe2WgRjCtYDOSIxe6rg/o.jpg',
   'is_closed': False,
   'location': {'address1': '940 Penn Ave',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['940 Penn Ave', 'Pittsburgh, PA 15222'],
    'state': 'PA',
    'zip_code': '15222'},
   'name': 'Bakersfield Penn Ave',
   'phone': '+14125865024',
   'price': '$$',
   'rating': 4.5,
   'review_count': 287,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/bakersfield-penn-ave-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'icecream', 'title': 'Ice Cream & Frozen Yogurt'},
    {'alias': 'sandwiches', 'title': 'Sandwiches'}],
   'coordinates': {'latitude': 40.4578599, 'longitude': -79.9254799},
   'display_phone': '(412) 404-8853',
   'distance': 4776.441940472,
   'id': 'millies-homemade-ice-cream-pittsburgh',
   'image_url': 'https://s3-media2.fl.yelpcdn.com/bphoto/4BXLsHJ8YRDqewpx65OP7A/o.jpg',
   'is_closed': False,
   'location': {'address1': '232 S Highland Ave',
    'address2': None,
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['232 S Highland Ave', 'Pittsburgh, PA 15206'],
    'state': 'PA',
    'zip_code': '15206'},
   'name': "Millie's Homemade Ice Cream",
   'phone': '+14124048853',
   'price': '$',
   'rating': 4.5,
   'review_count': 147,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/millies-homemade-ice-cream-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'cafes', 'title': 'Cafes'},
    {'alias': 'markets', 'title': 'Fruits & Veggies'},
    {'alias': 'grocery', 'title': 'Grocery'}],
   'coordinates': {'latitude': 40.4667510986328,
    'longitude': -79.982292175293},
   'display_phone': '(412) 322-0333',
   'distance': 2469.55395609,
   'id': 'pear-and-the-pickle-cafe-and-market-pittsburgh-4',
   'image_url': 'https://s3-media2.fl.yelpcdn.com/bphoto/BsRvDMuRKJ2ubORT6diWVw/o.jpg',
   'is_closed': False,
   'location': {'address1': '1800 Rialto St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['1800 Rialto St', 'Pittsburgh, PA 15212'],
    'state': 'PA',
    'zip_code': '15212'},
   'name': 'Pear and the Pickle, Cafe & Market',
   'phone': '+14123220333',
   'price': '$',
   'rating': 4.5,
   'review_count': 24,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/pear-and-the-pickle-cafe-and-market-pittsburgh-4?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'sushi', 'title': 'Sushi Bars'},
    {'alias': 'seafood', 'title': 'Seafood'},
    {'alias': 'seafoodmarkets', 'title': 'Seafood Markets'}],
   'coordinates': {'latitude': 40.4523086547852,
    'longitude': -79.981819152832},
   'display_phone': '(412) 434-7200',
   'distance': 880.3266183664,
   'id': 'penn-ave-fish-company-pittsburgh',
   'image_url': 'https://s3-media3.fl.yelpcdn.com/bphoto/n06nlRB-vM0MbSPnAmIBTw/o.jpg',
   'is_closed': False,
   'location': {'address1': '2208 Penn Ave',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['2208 Penn Ave', 'Pittsburgh, PA 15222'],
    'state': 'PA',
    'zip_code': '15222'},
   'name': 'Penn Ave Fish Company',
   'phone': '+14124347200',
   'price': '$$',
   'rating': 4.0,
   'review_count': 237,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/penn-ave-fish-company-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'italian', 'title': 'Italian'},
    {'alias': 'pizza', 'title': 'Pizza'},
    {'alias': 'bars', 'title': 'Bars'}],
   'coordinates': {'latitude': 40.4435995, 'longitude': -80.0003448},
   'display_phone': '(412) 281-5700',
   'distance': 1802.0443028079999,
   'id': 'proper-brick-oven-and-tap-room-pittsburgh',
   'image_url': 'https://s3-media2.fl.yelpcdn.com/bphoto/Be0_958CJfnyci5nJ28SAw/o.jpg',
   'is_closed': False,
   'location': {'address1': '139 7th St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['139 7th St', 'Pittsburgh, PA 15222'],
    'state': 'PA',
    'zip_code': '15222'},
   'name': 'Proper Brick Oven & Tap Room',
   'phone': '+14122815700',
   'price': '$$',
   'rating': 4.5,
   'review_count': 378,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/proper-brick-oven-and-tap-room-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'french', 'title': 'French'}],
   'coordinates': {'latitude': 40.4602131685326,
    'longitude': -79.9251211918181},
   'display_phone': '(412) 361-1340',
   'distance': 4883.085821176,
   'id': 'the-twisted-frenchman-pittsburgh',
   'image_url': 'https://s3-media4.fl.yelpcdn.com/bphoto/D3fYemf-RPJsJCKbavdc3g/o.jpg',
   'is_closed': False,
   'location': {'address1': '128 S Highland Ave',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['128 S Highland Ave', 'Pittsburgh, PA 15206'],
    'state': 'PA',
    'zip_code': '15206'},
   'name': 'The Twisted Frenchman',
   'phone': '+14123611340',
   'price': '$$$',
   'rating': 4.5,
   'review_count': 92,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/the-twisted-frenchman-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'tradamerican', 'title': 'American (Traditional)'},
    {'alias': 'pretzels', 'title': 'Pretzels'},
    {'alias': 'sandwiches', 'title': 'Sandwiches'}],
   'coordinates': {'latitude': 40.4280014038086,
    'longitude': -79.9722442626953},
   'display_phone': '(412) 431-2574',
   'distance': 1941.0217553199998,
   'id': 'the-pretzel-shop-pittsburgh',
   'image_url': 'https://s3-media4.fl.yelpcdn.com/bphoto/fE7vQMn2vYultreLOQbhfw/o.jpg',
   'is_closed': False,
   'location': {'address1': '2316 E Carson St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['2316 E Carson St', 'Pittsburgh, PA 15203'],
    'state': 'PA',
    'zip_code': '15203'},
   'name': 'The Pretzel Shop',
   'phone': '+14124312574',
   'price': '$',
   'rating': 4.5,
   'review_count': 89,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/the-pretzel-shop-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'sandwiches', 'title': 'Sandwiches'}],
   'coordinates': {'latitude': 40.4516599, 'longitude': -80.01756},
   'display_phone': '(412) 231-9009',
   'distance': 3339.598082768,
   'id': 'peppis-pittsburgh-3',
   'image_url': 'https://s3-media4.fl.yelpcdn.com/bphoto/WXJCbWFt7zCbwtP6SkvAiQ/o.jpg',
   'is_closed': False,
   'location': {'address1': '927 Western Ave',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['927 Western Ave', 'Pittsburgh, PA 15233'],
    'state': 'PA',
    'zip_code': '15233'},
   'name': "Peppi's",
   'phone': '+14122319009',
   'price': '$',
   'rating': 4.5,
   'review_count': 87,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/peppis-pittsburgh-3?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'tapasmallplates', 'title': 'Tapas/Small Plates'},
    {'alias': 'cocktailbars', 'title': 'Cocktail Bars'},
    {'alias': 'sandwiches', 'title': 'Sandwiches'}],
   'coordinates': {'latitude': 40.4286060880361,
    'longitude': -79.9866321310401},
   'display_phone': '(412) 918-1006',
   'distance': 1897.1036713899998,
   'id': 'streets-on-carson-pittsburgh',
   'image_url': 'https://s3-media3.fl.yelpcdn.com/bphoto/WkUTxH_IocDpbOrXBPH9nQ/o.jpg',
   'is_closed': False,
   'location': {'address1': '1120 E Carson St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['1120 E Carson St', 'Pittsburgh, PA 15203'],
    'state': 'PA',
    'zip_code': '15203'},
   'name': 'Streets On Carson',
   'phone': '+14129181006',
   'price': '$$',
   'rating': 4.5,
   'review_count': 70,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/streets-on-carson-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'localflavor', 'title': 'Local Flavor'},
    {'alias': 'landmarks', 'title': 'Landmarks & Historical Buildings'}],
   'coordinates': {'latitude': 40.4418551018066,
    'longitude': -80.0125872686642},
   'display_phone': '',
   'distance': 2851.618353186,
   'id': 'point-state-park-fountain-pittsburgh',
   'image_url': 'https://s3-media2.fl.yelpcdn.com/bphoto/FKp27WlmWQWiT343Kna3Hw/o.jpg',
   'is_closed': False,
   'location': {'address1': '',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['Pittsburgh, PA 15222'],
    'state': 'PA',
    'zip_code': '15222'},
   'name': 'Point State Park Fountain',
   'phone': '',
   'rating': 5.0,
   'review_count': 27,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/point-state-park-fountain-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'coffee', 'title': 'Coffee & Tea'}],
   'coordinates': {'latitude': 40.45163, 'longitude': -79.98285},
   'display_phone': '(412) 281-1922',
   'distance': 835.6787631199999,
   'id': 'la-prima-espresso-co-pittsburgh',
   'image_url': 'https://s3-media3.fl.yelpcdn.com/bphoto/j6lYrTYDiKntSDl5Qh2IwQ/o.jpg',
   'is_closed': False,
   'location': {'address1': '205 21st St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['205 21st St', 'Pittsburgh, PA 15222'],
    'state': 'PA',
    'zip_code': '15222'},
   'name': 'La Prima Espresso Co',
   'phone': '+14122811922',
   'price': '$',
   'rating': 4.5,
   'review_count': 96,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/la-prima-espresso-co-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'thai', 'title': 'Thai'},
    {'alias': 'noodles', 'title': 'Noodles'}],
   'coordinates': {'latitude': 40.457748, 'longitude': -79.925491},
   'display_phone': '',
   'distance': 4762.941187212,
   'id': 'noodlehead-pittsburgh',
   'image_url': 'https://s3-media1.fl.yelpcdn.com/bphoto/yYVAt2SYFsNa772EM61PXg/o.jpg',
   'is_closed': False,
   'location': {'address1': '242 S Highland Ave',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['242 S Highland Ave', 'Pittsburgh, PA 15206'],
    'state': 'PA',
    'zip_code': '15206'},
   'name': 'Noodlehead',
   'phone': '',
   'price': '$',
   'rating': 4.5,
   'review_count': 651,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/noodlehead-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'coffee', 'title': 'Coffee & Tea'},
    {'alias': 'mediterranean', 'title': 'Mediterranean'},
    {'alias': 'juicebars', 'title': 'Juice Bars & Smoothies'}],
   'coordinates': {'latitude': 40.42899, 'longitude': -79.98074},
   'display_phone': '(412) 927-4030',
   'distance': 1751.060411608,
   'id': 'delanies-coffee-pittsburgh',
   'image_url': 'https://s3-media1.fl.yelpcdn.com/bphoto/QqWn7WXJI1ay4mTa1Ec_CQ/o.jpg',
   'is_closed': False,
   'location': {'address1': '1737 E Carson St',
    'address2': '',
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['1737 E Carson St', 'Pittsburgh, PA 15203'],
    'state': 'PA',
    'zip_code': '15203'},
   'name': "Delanie's Coffee",
   'phone': '+14129274030',
   'price': '$',
   'rating': 4.5,
   'review_count': 113,
   'transactions': [],
   'url': 'https://www.yelp.com/biz/delanies-coffee-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'},
  {'categories': [{'alias': 'italian', 'title': 'Italian'}],
   'coordinates': {'latitude': 40.455, 'longitude': -79.97874},
   'display_phone': '(412) 918-1875',
   'distance': 1139.6553119116,
   'id': 'dianoias-eatery-pittsburgh-2',
   'image_url': 'https://s3-media1.fl.yelpcdn.com/bphoto/IcJ2xaRB9N2RHXH3OfVanQ/o.jpg',
   'is_closed': False,
   'location': {'address1': '2549 Penn Ave',
    'address2': None,
    'address3': '',
    'city': 'Pittsburgh',
    'country': 'US',
    'display_address': ['2549 Penn Ave', 'Pittsburgh, PA 15222'],
    'state': 'PA',
    'zip_code': '15222'},
   'name': "DiAnoia's Eatery",
   'phone': '+14129181875',
   'price': '$$',
   'rating': 4.5,
   'review_count': 89,
   'transactions': ['pickup'],
   'url': 'https://www.yelp.com/biz/dianoias-eatery-pittsburgh-2?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'}],
 'region': {'center': {'latitude': 40.44467404448069,
   'longitude': -79.97909545898438}},
 'total': 11589}

In [45]:
# see how much data do we have? 
len(search_response.json()['businesses'])


Out[45]:
50

Automating Data Collection

  • According to the documentation we can get information about up to 1000 businesses and we can only request information about 50 businesses at a time.
  • This means we need to make a loop that makes a series of requests to get all the information
  • Each iteration of the loop will use the offset parameter to request different information

In [46]:
# A short script to download all available information about 
# 1000 businesses in the Pittsburhg area


# request endpoint
SEARCH_URL = "https://api.yelp.com/v3/businesses/search"

# parameters
SEARCH_LOCATION = "Pittsburgh"
SEARCH_LIMIT = 50
SEARCH_TERM = ""


# create a container list to hold our results
yelp_business_data = []


# loop
for offset in range(0,1000,50):
    # Print the where we are in the loop
    print("Requesting offset {}".format(offset))
    
    # make the HTTP request to the Yelp business search endpoint
    search_response = requests.get(SEARCH_URL,
                               headers={"Authorization":"Bearer {}".format(authentication_token)},
                               params={"term": SEARCH_TERM,
                                       "location": SEARCH_LOCATION,
                                       "limit": SEARCH_LIMIT,
                                       "offset": offset})
    # put the results in the container list
    yelp_business_data.extend(search_response.json()['businesses'])

# print total when loop is completed
print("Collected information about {} businesses".format(len(yelp_business_data)))


Requesting offset 0
Requesting offset 50
Requesting offset 100
Requesting offset 150
Requesting offset 200
Requesting offset 250
Requesting offset 300
Requesting offset 350
Requesting offset 400
Requesting offset 450
Requesting offset 500
Requesting offset 550
Requesting offset 600
Requesting offset 650
Requesting offset 700
Requesting offset 750
Requesting offset 800
Requesting offset 850
Requesting offset 900
Requesting offset 950
Collected information about 1000 businesses

In [47]:
yelp_business_data[0]


Out[47]:
{'categories': [{'alias': 'gardens', 'title': 'Botanical Gardens'},
  {'alias': 'parks', 'title': 'Parks'}],
 'coordinates': {'latitude': 40.439248, 'longitude': -79.947347},
 'display_phone': '(412) 622-6914',
 'distance': 2753.5113774459996,
 'id': 'phipps-conservatory-and-botanical-gardens-pittsburgh',
 'image_url': 'https://s3-media3.fl.yelpcdn.com/bphoto/gVY6b6FGf29TPpyRfec_eA/o.jpg',
 'is_closed': False,
 'location': {'address1': '1 Schenley Park',
  'address2': None,
  'address3': '',
  'city': 'Pittsburgh',
  'country': 'US',
  'display_address': ['1 Schenley Park', 'Pittsburgh, PA 15213'],
  'state': 'PA',
  'zip_code': '15213'},
 'name': 'Phipps Conservatory and Botanical Gardens',
 'phone': '+14126226914',
 'rating': 4.5,
 'review_count': 208,
 'transactions': [],
 'url': 'https://www.yelp.com/biz/phipps-conservatory-and-botanical-gardens-pittsburgh?adjust_creative=4EDvg4OOFwJB-NT-tovQZQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=4EDvg4OOFwJB-NT-tovQZQ'}

Inspecting the Data

  • Now we have data for 1000 businesses in the Pittsburgh area. Why don't we try and learn something!
  • First step is to make these data more tabular so we can load it into a Pandas Dataframe

In [48]:
from numpy import nan
%matplotlib inline

# a short function to extract the data we want from a single business entry
def extract_info(business):
    """Extracts a few of the datapoints from the business data"""
    return {
        "id":business['id'],
        "name":business['name'],
        "rating":business['rating'],
        "review_count":business['review_count'],
        "price": business['price'] if 'price' in business else nan
        
    }

# use a list comprehension to process the data
extracted_data = [extract_info(biz) for biz in yelp_business_data]

# look at the first five entries 
extracted_data[0:3]


Out[48]:
[{'id': 'phipps-conservatory-and-botanical-gardens-pittsburgh',
  'name': 'Phipps Conservatory and Botanical Gardens',
  'price': nan,
  'rating': 4.5,
  'review_count': 208},
 {'id': 'la-gourmandine-bakery-and-pastry-shop-pittsburgh',
  'name': 'La Gourmandine Bakery & Pastry Shop',
  'price': '$',
  'rating': 4.5,
  'review_count': 319},
 {'id': 'amazing-cafe-pittsburgh',
  'name': 'Amazing Cafe',
  'price': '$$',
  'rating': 4.5,
  'review_count': 92}]

In [49]:
# load pandas so we can use Dataframes
import pandas as pd

# load the extracted data into a Pandas Dataframe
yelp_dataframe = pd.DataFrame(extracted_data)

# look at the first 5 entries
yelp_dataframe.head()


Out[49]:
id name price rating review_count
0 phipps-conservatory-and-botanical-gardens-pitt... Phipps Conservatory and Botanical Gardens NaN 4.5 208
1 la-gourmandine-bakery-and-pastry-shop-pittsburgh La Gourmandine Bakery & Pastry Shop $ 4.5 319
2 amazing-cafe-pittsburgh Amazing Cafe $$ 4.5 92
3 randyland-pittsburgh Randyland $ 5.0 34
4 espresso-a-mano-pittsburgh Espresso A Mano $ 4.5 265

In [50]:
# inspect the datatypes
yelp_dataframe.dtypes


Out[50]:
id               object
name             object
price            object
rating          float64
review_count      int64
dtype: object

In [51]:
# Get some quick summary statistics about the numeric data
yelp_dataframe.describe()


Out[51]:
rating review_count
count 1000.000000 1000.000000
mean 4.006000 89.016000
std 0.521763 109.548211
min 2.500000 3.000000
25% 3.500000 26.000000
50% 4.000000 54.000000
75% 4.500000 106.250000
max 5.000000 1279.000000

In [52]:
# look at the lowest rated businesses in Pittsburgh
yelp_dataframe.sort_values("rating").head(10)


Out[52]:
id name price rating review_count
950 steel-cactus-pittsburgh-2 Steel Cactus $$ 2.5 205
805 lulus-noodles-pittsburgh Lulu's Noodles $ 2.5 339
941 rolands-seafood-grill-pittsburgh Roland's Seafood Grill $$ 2.5 251
699 nakama-pittsburgh Nakama $$ 3.0 251
694 mccormick-and-schmicks-seafood-and-steaks-pitt... McCormick & Schmick's Seafood & Steaks $$ 3.0 108
803 sushi-too-pittsburgh Sushi Too $$ 3.0 93
931 sakura-teppanyaki-and-sushi-pittsburgh Sakura Teppanyaki & Sushi $$ 3.0 91
825 cains-saloon-pittsburgh Cain's Saloon $$ 3.0 128
698 orient-express-pittsburgh Orient Express $ 3.0 81
504 six-penn-kitchen-pittsburgh Six Penn Kitchen $$ 3.0 258

In [53]:
# look at the 10 highest rated business in Pittsburgh
yelp_dataframe.sort_values("rating", ascending=False).head(10)


Out[53]:
id name price rating review_count
708 walters-automotive-pittsburgh Walter's Automotive NaN 5.0 106
170 north-shore-deli-pittsburgh North Shore Deli $ 5.0 17
757 christopher-p-hayner-dmd-pittsburgh Christopher P Hayner, DMD NaN 5.0 22
762 bicycle-heaven-pittsburgh Bicycle Heaven $ 5.0 68
768 colangelos-bakery-pittsburgh Colangelo's Bakery $$ 5.0 39
90 groceria-merante-pittsburgh Groceria Merante $ 5.0 25
163 west-end-elliott-overlook-pittsburgh West End - Elliott Overlook NaN 5.0 18
166 schenley-park-pittsburgh-2 Schenley Park NaN 5.0 14
779 the-culturals-elite-pittsburgh The Cultural's Elite $$ 5.0 25
798 pregame-pittsburgh Pregame $ 5.0 5

In [54]:
# look at the most reviewed businesses in Pittsburgh
yelp_dataframe.sort_values("review_count", ascending=False).head(10)


Out[54]:
id name price rating review_count
197 meat-and-potatoes-pittsburgh Meat & Potatoes $$$ 4.0 1279
292 primanti-bros-pittsburgh-15 Primanti Bros. $ 3.5 998
28 gaucho-parrilla-argentina-pittsburgh Gaucho Parrilla Argentina $$ 4.5 977
238 church-brew-works-pittsburgh Church Brew Works $$ 3.5 812
47 noodlehead-pittsburgh Noodlehead $ 4.5 651
71 fat-heads-saloon-pittsburgh Fat Heads Saloon $$ 4.0 600
11 täkō-pittsburgh täkō $$ 4.5 577
20 butcher-and-the-rye-pittsburgh Butcher and the Rye $$$ 4.5 570
118 sienna-mercato-pittsburgh Sienna Mercato $$ 4.0 548
401 primanti-bros-pittsburgh Primanti Bros $ 3.5 525

In [55]:
# look at the most expensive resturants in Pittsburgh
yelp_dataframe.sort_values("price", ascending=False).head(10)


Out[55]:
id name price rating review_count
628 tmd-pittsburgh TMD $$$$ 4.5 6
380 mortons-the-steakhouse-pittsburgh Morton's The Steakhouse $$$$ 3.5 76
33 alla-famiglia-pittsburgh Alla Famiglia $$$$ 4.5 135
84 the-capital-grille-pittsburgh The Capital Grille $$$$ 4.0 201
220 umi-pittsburgh Umi $$$$ 4.0 118
263 ruths-chris-steak-house-pittsburgh Ruths Chris Steak House $$$$ 4.0 89
168 avenue-b-pittsburgh Avenue B $$$ 4.0 202
183 the-melting-pot-pittsburgh The Melting Pot $$$ 4.0 115
41 the-twisted-frenchman-pittsburgh The Twisted Frenchman $$$ 4.5 92
553 social-house-seven-pittsburgh Social House Seven $$$ 3.5 90

In [56]:
# how are the ratings distributed
yelp_dataframe['rating'].hist(bins=5)


Out[56]:
<matplotlib.axes._subplots.AxesSubplot at 0x10481aac8>

In [57]:
# how are the review counts distributed
yelp_dataframe['review_count'].hist(bins=100)


Out[57]:
<matplotlib.axes._subplots.AxesSubplot at 0x109f78d68>

More resources on APIs and Python