San Diego Burrito Analytics: Coordinates

Determine the longitude and latitude for each restaurant based on its address

Default imports


In [1]:
%config InlineBackend.figure_format = 'retina'
%matplotlib inline

import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
import pandas as pd

import seaborn as sns
sns.set_style("white")

Load data


In [17]:
import util2
df, dfRestaurants, dfIngredients = util2.load_burritos()
N = df.shape[0]

Process


In [18]:
dfRestaurants=dfRestaurants.reset_index().drop('index',axis=1)

In [19]:
dfRestaurants


Out[19]:
Location Neighborhood Address URL Yelp Google Chips
0 Donato's taco shop Miramar 6780 Miramar Rd http://donatostacoshop.net/ 3.5 4.2 False
1 Oscar's Mexican food San Marcos 225 S Rancho Santa Fe Rd http://www.yelp.com/biz/oscars-mexican-food-sa... 3.5 3.3 False
2 Pollos Maria Carlsbad 3055 Harding St http://pollosmaria.com/ 4.0 3.8 True
3 Nico's Taco Shop Carmel Valley 3860 Valley Centre Dr #404 http://www.yelp.com/biz/nicos-taco-shop-san-diego 3.0 2.9 False
4 Los Primos Mexican Food UTC 7770 Regents Rd http://www.primosmex.com/ 3.0 3.7 True
5 JV's Mexican Food Morena 1112 Morena Blvd http://jvsmexfood.com/ 4.0 4.1 False
6 Tony's Fresh Mexican Food Miramar 7122 Miramar Rd https://www.yelp.com/biz/tonys-fresh-mexican-f... 3.0 4.1 True
7 Taco Stand La Jolla 621 Pearl St http://letstaco.com/ 4.5 4.4 False
8 Graciela's Taco Shop Bonita 5047 Central Ave https://www.yelp.com/biz/gracielas-taco-shop-b... 4.0 4.5 False
9 Rigoberto's Taco Shop La Jolla La Jolla 7345 La Jolla Blvd https://www.yelp.com/biz/rigobertos-la-jolla-2 2.5 4.0 False
10 Lolita's taco shop Kearny Mesa 7305 Clairemont Mesa Blvd http://lolitasmexicanfood.com/ 4.0 4.4 False
11 Lola's 7 Up Market & Deli Carlsbad 3292 Roosevelt St https://www.yelp.com/biz/lolas-7-up-market-and... 4.5 4.9 False
12 Colima's Mexican Food North park 2302 University Ave https://www.yelp.com/biz/colimas-mexican-food-... 4.0 4.2 False
13 Rigoberto's Taco Shop Miramar 7094 Miramar Rd https://www.yelp.com/biz/rigobertos-taco-shop-... 4.0 4.4 False
14 Raul's Mexican food Encinitas 490 S Coast Hwy 101 https://www.yelp.com/biz/rauls-shack-encinitas 4.0 4.2 False
15 El Zarape University Heights 4642 Park Blvd https://www.yelp.com/biz/el-zarape-san-diego 4.0 4.4 True
16 El Indio San Diego 3695 India St http://elindiosandiego.com/ 3.5 3.9 False
17 Cancun Mexican & Seafood Encinitas 1766 N Coast Hwy http://cancunmexicanandseafood.com/ 4.5 4.1 True
18 Vallarta express Clairemont 4277 Genesee Ave http://www.vallartaexpress.com/menu/ 3.5 4.0 False
19 Mikes Taco Club Ocean Beach 5060 Newport Ave http://www.mikestacoclub.com/menu/ 4.5 4.9 False
20 La Perla Cocina Pacific Beach 745 Emerald St https://www.yelp.com/biz/la-perla-cocina-mexic... 4.5 4.7 False
21 Rudy's Taco Shop Solana Beach 524 Stevens Ave http://www.rudystacoshop.com/ 4.0 4.3 False
22 California Burritos Linda Vista 7754 Starling Dr https://www.yelp.com/biz/california-burritos-s... 4.5 4.4 True
23 Jorge's Mexicatessen Encinitas 267 N El Camino Rea https://www.yelp.com/biz/jorges-mexicatessen-e... 4.0 4.5 False
24 Senor Grubby's Carlsbad 377 Carlsbad Village Dr eatgrubbys.com 4.0 4.1 False
25 Mi Asador Mexican & Seafood Oceanside 4750 Oceanside Blvd https://sites.google.com/site/miasador/ 4.5 4.4 True
26 Sotos Mexican Food Miramar 6904 Miramar Rd https://www.yelp.com/biz/sotos-mexican-food-sa... 4.5 4.6 True
27 Karina's Taco Shop Encinitas 916 N Coast Hwy 101 https://www.yelp.com/biz/karinas-taco-shop-enc... 4.0 4.2 False
28 Juanita's Taco Shop Encinitas 290 N Coast Hwy 101 https://www.yelp.com/biz/juanitas-taco-shop-en... 4.0 4.5 False
29 Goody's La Jolla Marshall College https://www.yelp.com/biz/goodys-place-and-mark... 3.5 4.1 False
... ... ... ... ... ... ... ...
36 El Rey Moro Clairemont 4471 Clairemont Mesa Blvd https://www.yelp.com/biz/el-rey-moro-taco-shop... 4.0 3.8 False
37 Papa Chito's Mexican Food University City 3951 Governor Dr https://www.yelp.com/biz/papa-chitos-mexican-f... 2.5 3.3 False
38 El Pueblo Mexican Food Cardiff 820 Birmingham Dr https://www.yelp.com/biz/el-pueblo-authentic-m... 4.0 4.7 False
39 Burros and Fries Clairemont 4705 Clairemont Dr http://www.burrosandfries.com/ 3.5 4.1 False
40 King Burrito Oceanside 3490 Marron Rd https://www.yelp.com/biz/king-burrito-oceanside-2 4.0 3.9 False
41 Carmen's Mexican Food Clairemont 4937 Diane Ave https://www.yelp.com/biz/carmens-authentic-mex... 4.0 4.2 False
42 Senor Panchos San Marcos 1909 W San Marcos Blvd https://www.yelp.com/biz/senor-panchos-mexican... 4.0 4.2 False
43 Los Cabos San Marcos 165 S Rancho Santa Fe Rd https://www.yelp.com/biz/los-cabos-san-marcos 4.0 4.1 True
44 Rubios UCSD UTC 9500 Gilman Dr https://www.yelp.com/biz/rubios-la-jolla-4 3.5 3.4 True
45 Lucha Libre North Park North Park 3016 University Ave https://www.yelp.com/biz/lucha-libre-san-diego 3.5 4.3 True
46 Roberto's Taco Shop Clairemont Clairemont 3095 Clairemont Dr https://www.yelp.com/biz/robertos-taco-shop-cl... 4.0 4.0 False
47 Chipotle Carlsbad 2505 Palomar airport Rd https://www.yelp.com/biz/chipotle-mexican-gril... 3.0 4.2 False
48 El Cuervo Hillcrest 110 Washington St https://www.yelp.com/biz/el-cuervo-taco-shop-s... 4.0 4.3 False
49 El Torrito Foods Vista 249 Emerald Dr https://www.yelp.com/biz/el-torito-foods-vista-2 4.0 4.4 False
50 La Morena Taco Shop and Seafood Webster 5059 Federal Blvd https://www.yelp.com/biz/la-morena-taco-shop-s... 4.5 4.7 False
51 Taco Villa UTC 9500 Gilman Dr https://www.yelp.com/biz/taco-villa-san-diego 3.0 NaN False
52 Valentines Mexican Food Downtown 1157 Sixth Ave https://www.yelp.com/biz/valentines-mexican-fo... 4.0 4.0 True
53 Matador Mexican Food Morena 5201 Linda Vista Rd https://www.yelp.com/biz/matador-mexican-grill... 4.5 4.0 True
54 Jose's Taco Oceanside 3910 Vista Way https://www.yelp.com/biz/joses-taco-oceanside 4.0 3.8 False
55 Cortez Mexican Food Bonsall 5517 Mission Rd https://www.yelp.com/biz/cortez-mexican-food-b... 4.2 4.0 False
56 California Burrito Company Miramar 6912 Miramar Rd https://www.yelp.com/biz/california-burrito-co... 3.5 4.4 False
57 Taco Stand Encinitas Encinitas 642 S Coast Hwy 101 https://www.yelp.com/biz/the-taco-stand-encinitas 4.0 4.4 False
58 Ortiz's Taco Shop #2 Pacific Beach 1313 Garnet Ave https://www.yelp.com/biz/ortizs-taco-shop-san-... 4.0 4.2 False
59 El Portal Fresh Mexican Grill Clairemont 4101 Genesee Ave https://www.yelp.com/biz/el-portal-fresh-mexic... 4.0 4.4 True
60 Famoso Mexican Street Food Downtown 815 C St https://www.yelp.com/biz/famoso-mexican-street... 4.5 3.9 False
61 Los Panchos Taco Shop Hillcrest 409 Washington St https://www.yelp.com/biz/los-panchos-san-diego-2 3.0 3.4 True
62 El Pollo Loco Oceanside 3500 College Blvd https://www.yelp.com/biz/el-pollo-loco-oceansi... 3.5 4.1 False
63 Gloria's Taco Shop South Park 1233 28th St https://www.yelp.com/biz/glorias-taco-shop-san... 4.0 4.3 False
64 Mr. Ruribertos Taco Shop Mission Beach 3202 Mission Blvd https://www.yelp.com/biz/ruribertos-taco-shop-... 3.5 3.7 False
65 Mister Falafel Clairemont 4461 Clairemont Mesa Blvd https://www.yelp.com/biz/mister-falafel-san-diego 4.5 4.6 False

66 rows × 7 columns

Process Cali burrito data: Averages for each restaurant


In [20]:
dfAvg = df.groupby('Location').agg({'Cost': np.mean,'Volume': np.mean,'Hunger': np.mean,
                                'Tortilla': np.mean,'Temp': np.mean,'Meat': np.mean,
                                'Fillings': np.mean,'Meat:filling': np.mean,'Uniformity': np.mean,
                                'Salsa': np.mean,'Synergy': np.mean,'Wrap': np.mean,
                                'overall': np.mean, 'Location':np.size})
dfAvg.rename(columns={'Location': 'N'}, inplace=True)
dfAvg['Location'] = list(dfAvg.index)

In [21]:
# Calculate latitutude and longitude for each city
import geocoder
addresses = dfRestaurants['Address'] + ', San Diego, CA'
lats = np.zeros(len(addresses))
longs = np.zeros(len(addresses))
for i, address in enumerate(addresses):
    g = geocoder.google(address)
    Ntries = 1
    while g.latlng ==[]:
        g = geocoder.google(address)
        Ntries +=1
        print 'try again: ' + address
        if Ntries >= 5:
            if 'Marshall College' in address:
                address = '9500 Gilman Drive, La Jolla, CA'
                g = geocoder.google(address)
                Ntries = 1
                while g.latlng ==[]:
                    g = geocoder.google(address)
                    Ntries +=1
                    print 'try again: ' + address
                    if Ntries >= 5:
                        raise ValueError('Address not found: ' + address)
            else:
                raise ValueError('Address not found: ' + address)
    lats[i], longs[i] = g.latlng
    
# # Check for nonsense lats and longs
if sum(np.logical_or(lats>34,lats<32)):
    raise ValueError('Address not in san diego')
if sum(np.logical_or(longs<-118,longs>-117)):
    raise ValueError('Address not in san diego')


try again: Marshall College, San Diego, CA
try again: Marshall College, San Diego, CA
try again: Marshall College, San Diego, CA
try again: Marshall College, San Diego, CA

In [22]:
# Incorporate lats and longs into restaurants data
dfRestaurants['Latitude'] = lats
dfRestaurants['Longitude'] = longs
# Merge restaurant data with burrito data
dfTableau = pd.merge(dfRestaurants,dfAvg,on='Location')

In [23]:
dfTableau.head()


Out[23]:
Location Neighborhood Address URL Yelp Google Chips Latitude Longitude Fillings ... N Tortilla Synergy Uniformity Hunger Meat:filling Volume Cost Wrap Salsa
0 Donato's taco shop Miramar 6780 Miramar Rd http://donatostacoshop.net/ 3.5 4.2 False 32.878996 -117.168846 3.500000 ... 1 3.000000 4.000000 4.000000 3.000000 4.000000 NaN 6.490000 4.000000 4.000
1 Oscar's Mexican food San Marcos 225 S Rancho Santa Fe Rd http://www.yelp.com/biz/oscars-mexican-food-sa... 3.5 3.3 False 33.145203 -117.200290 2.833333 ... 3 2.666667 3.166667 4.333333 2.333333 3.500000 NaN 5.183333 5.000000 3.500
2 Pollos Maria Carlsbad 3055 Harding St http://pollosmaria.com/ 4.0 3.8 True 33.161188 -117.344319 3.625000 ... 4 3.500000 4.250000 3.500000 3.625000 3.375000 0.615000 6.765000 2.500000 2.625
3 Nico's Taco Shop Carmel Valley 3860 Valley Centre Dr #404 http://www.yelp.com/biz/nicos-taco-shop-san-diego 3.0 2.9 False 32.939136 -117.232163 2.250000 ... 2 2.250000 2.250000 3.000000 2.750000 2.750000 NaN 7.090000 3.000000 NaN
4 Los Primos Mexican Food UTC 7770 Regents Rd http://www.primosmex.com/ 3.0 3.7 True 32.862750 -117.224335 3.090909 ... 11 3.363636 2.545455 2.750000 3.318182 1.909091 0.761429 7.077273 3.454545 3.000

5 rows × 23 columns


In [24]:
dfTableau.to_csv('df_burrito_tableau.csv')