San Diego Burrito Analytics: Lucha Libre Taco Shop

Scott Cole

31 August 2016

This analysis focuses on the 28 burritos reviewed at Lucha Libre

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 [2]:
import util2
df, dfRestaurants, dfIngredients = util2.load_burritos()
N = df.shape[0]
dfLuchaLibre = df[df.Location=='lucha libre north park']

Distribution of burritos


In [3]:
# Number of each type of burrito
ll_types = {'Veggie':'veg', 'Surf & Turf':'surf.*turf', 'Holy Moly':'moly', 'Bean & cheese':'bean.*cheese',
                            'California':'California - ', 'Surfin California':'surfin', 'Nutty':'nutty'}
def burritotypes(x, types):
    import re
    T = len(types)
    Nmatches = {}
    imatches = {}
    burrito_new = []
    for i, b in enumerate(x):
        matched = False
        for t in types.keys():
            re4str = re.compile('.*'+types[t]+'.*', re.IGNORECASE)
            if np.logical_and(re4str.match(b) is not None, matched is False):
                try:
                    Nmatches[t] +=1
                    imatches[t].append(x.index[i])
                    burrito_new.append(t)
                except KeyError:
                    Nmatches[t] = 1
                    imatches[t] = [x.index[i]]
                    burrito_new.append(t)
                matched = True
        if matched is False:
            try:
                Nmatches['other'] +=1
                burrito_new.append('other')
            except KeyError:
                Nmatches['other'] = 1
                burrito_new.append('other')
    return Nmatches, imatches, burrito_new

typecounts, imatches, burrito_new = burritotypes(dfLuchaLibre.Burrito,ll_types)

plt.figure(figsize=(6,6))
ax = plt.axes([0.1, 0.1, 0.65, 0.65])

# The slices will be ordered and plotted counter-clockwise.
labels = typecounts.keys()
fracs = typecounts.values()
explode=[.1]*len(typecounts)

patches, texts, autotexts = plt.pie(fracs, explode=explode, labels=labels,
                autopct=lambda(p): '{:.0f}'.format(p * np.sum(fracs) / 100), shadow=False, startangle=0)
                # The default startangle is 0, which would start
                # the Frogs slice on the x-axis.  With startangle=90,
                # everything is rotated counter-clockwise by 90 degrees,
                # so the plotting starts on the positive y-axis.


for t in texts:
    t.set_size(20)
for t in autotexts:
    t.set_size(20)
autotexts[0].set_color('w')
autotexts[6].set_color('w')
figname = 'luchalibre_types'
#plt.savefig('C:/gh/srcole.github.io/assets/burrito/'+figname + '.png')



In [4]:
# Look at volume across burritos, but export to csv to import to R for better plotting
ll_types = {'Surf & Turf':'surf.*turf', 'Holy Moly':'moly', 'California':'California - ', 'Surfin California':'surfin'}
typecounts, imatches, burrito_new = burritotypes(dfLuchaLibre.Burrito,ll_types)
# Create new column of simple burrito name
dfLuchaLibre['Burrito2'] = burrito_new

from ggplot import *
ggplot(aes(x='Burrito2',y='Volume'),data=dfLuchaLibre)+ geom_boxplot()+ylab(element_text(size=25,text='Volume (L)'))+\
    xlab(element_text(size=25,text='Burrito type'))
#dfLuchaLibre.to_csv('llburritoplt.csv')


C:\Users\Scott\Anaconda2\lib\site-packages\ipykernel\__main__.py:5: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
Out[4]:
<ggplot: (28282849)>

Average each metric over each Location


In [5]:
m_Location = ['Location','N','Hunger','Cost','Volume','Tortilla','Temp','Meat','Fillings','Meat:filling',
               'Uniformity','Salsa','Synergy','Wrap','overall']

# Calculate the mean of each of the metrics above for each taco shop
tacoshops = df.Location.unique()
TS = len(tacoshops)
dfmean = pd.DataFrame(np.nan, index=range(TS), columns=m_Location)
for ts in range(TS):
    dfmean.loc[ts] = df.loc[df.Location==tacoshops[ts]].mean()
    dfmean['N'][ts] = sum(df.Location == tacoshops[ts])
dfmean.Location = tacoshops

In [6]:
dfmean


Out[6]:
Location N Hunger Cost Volume Tortilla Temp Meat Fillings Meat:filling Uniformity Salsa Synergy Wrap overall
0 donato's taco shop 1.0 3.000000 6.490000 NaN 3.000000 5.000000 3.000000 3.500000 4.000000 4.000000 4.000000 4.000000 4.000000 3.800000
1 oscar's mexican food 3.0 2.333333 5.183333 NaN 2.666667 2.500000 2.833333 2.833333 3.500000 4.333333 3.500000 3.166667 5.000000 3.250000
2 pollos maria 2.0 4.000000 6.790000 NaN 3.500000 4.500000 4.500000 3.500000 3.500000 3.750000 2.500000 4.250000 2.500000 3.700000
3 nico's taco shop 2.0 2.750000 7.090000 NaN 2.250000 3.000000 3.000000 2.250000 2.750000 3.000000 NaN 2.250000 3.000000 2.800000
4 los primos mexican food 11.0 3.318182 7.077273 0.761429 3.363636 3.500000 2.863636 3.090909 1.909091 2.750000 3.000000 2.545455 3.454545 2.645455
5 jv's mexican food 2.0 2.750000 7.875000 NaN 2.500000 2.000000 2.125000 2.750000 3.500000 2.500000 1.000000 2.500000 4.000000 2.250000
6 tony's fresh mexican food 4.0 2.875000 6.610000 NaN 3.250000 2.833333 2.750000 2.875000 3.500000 3.875000 1.666667 3.375000 3.500000 2.912500
7 taco stand 19.0 3.078947 7.574737 0.768889 3.657895 3.289474 4.236842 3.868421 3.868421 3.789474 3.631579 4.131579 4.052632 4.063158
8 graciela's taco shop 2.0 2.500000 5.990000 NaN 3.750000 4.000000 3.250000 3.500000 4.000000 4.500000 4.000000 4.000000 3.000000 4.000000
9 rigoberto's taco shop la jolla 2.0 3.250000 6.400000 NaN 3.250000 3.500000 2.875000 3.000000 4.000000 3.000000 1.750000 NaN 4.750000 3.250000
10 lolita's taco shop 12.0 3.141667 7.225000 0.747778 2.983333 3.275000 3.363636 3.641667 3.354545 2.991667 2.854167 3.437500 3.916667 3.283333
11 lola's 7 up market & deli 2.0 3.500000 6.500000 NaN 2.500000 2.750000 3.000000 4.000000 3.000000 3.000000 3.000000 3.500000 2.500000 3.400000
12 colima's mexican food 3.0 4.166667 6.423333 NaN 3.166667 4.833333 3.833333 3.833333 4.000000 3.833333 3.000000 3.666667 4.000000 3.666667
13 rigoberto's taco shop 11.0 3.590909 6.827273 0.890000 3.545455 3.863636 3.681818 3.590909 4.000000 3.772727 3.593750 3.818182 3.772727 3.722727
14 raul's mexican food 2.0 2.250000 5.000000 NaN 2.000000 NaN 1.750000 1.500000 1.250000 1.500000 1.750000 1.750000 4.000000 1.500000
15 el zarape 4.0 2.562500 7.062500 NaN 3.125000 4.500000 3.875000 3.187500 3.875000 3.200000 3.000000 3.100000 4.625000 3.008332
16 el indio 1.0 4.000000 7.840000 NaN 4.000000 4.000000 3.500000 4.000000 4.500000 4.000000 3.500000 3.500000 4.500000 4.000000
17 cancun mexican & seafood 2.0 3.500000 6.490000 NaN 4.000000 4.000000 3.750000 3.750000 3.750000 3.000000 2.000000 3.750000 2.250000 4.050000
18 vallarta express 9.0 3.500000 6.933333 0.880000 2.916667 4.357143 3.277778 3.444444 3.611111 3.166667 3.500000 3.000000 3.611111 3.500000
19 mikes taco club 2.0 3.000000 8.590000 NaN 4.250000 4.500000 3.750000 4.750000 3.250000 3.000000 4.000000 4.500000 4.500000 4.400000
20 la perla cocina 2.0 3.250000 8.990000 NaN 4.000000 4.250000 2.750000 3.500000 2.250000 2.500000 2.500000 2.250000 3.500000 3.250000
21 porkyland 3.0 2.500000 8.216667 NaN 3.500000 4.166667 3.666667 4.166667 3.000000 3.166667 3.333333 3.000000 5.000000 3.766667
22 rudy's taco shop 2.0 3.250000 6.600000 NaN 3.250000 2.750000 3.500000 4.250000 2.500000 1.000000 3.000000 3.500000 2.750000 2.900000
23 california burritos 19.0 3.911053 6.250000 0.823571 3.963158 3.436842 4.000000 3.947368 3.986842 3.842105 3.611111 4.052632 4.342105 4.129412
24 jorge's mexicatessen 2.0 3.250000 5.725000 0.770000 2.250000 3.250000 3.250000 3.500000 3.000000 4.250000 3.750000 4.000000 4.500000 3.400000
25 senor grubby's 2.0 2.000000 9.000000 0.740000 2.250000 3.000000 2.250000 2.000000 1.000000 1.500000 2.500000 1.750000 4.250000 1.650000
26 mi asador mexican & seafood 2.0 3.000000 6.640000 0.945000 3.500000 2.750000 2.750000 3.000000 2.750000 2.500000 3.500000 3.500000 3.750000 3.250000
27 sotos mexican food 2.0 2.500000 6.370000 0.880000 4.250000 3.000000 2.750000 4.000000 2.500000 3.000000 4.000000 3.750000 4.750000 3.350000
28 karina's taco shop 2.0 2.750000 7.490000 0.955000 3.750000 4.000000 3.750000 3.500000 2.750000 2.250000 4.000000 3.750000 3.500000 3.750000
29 juanita's taco shop 2.0 3.000000 5.550000 0.785000 4.250000 4.250000 3.250000 3.500000 4.250000 3.500000 3.500000 3.500000 5.000000 3.700000
30 goody's 1.0 3.500000 7.250000 0.750000 1.500000 1.000000 2.000000 2.000000 2.000000 2.000000 2.000000 2.000000 1.000000 1.800000
31 taco surf pb 3.0 3.900000 6.766667 0.810000 4.166667 2.000000 3.933333 4.133333 4.000000 2.833333 3.600000 4.066667 4.666667 4.066667
32 roberto's very mexican food 2.0 2.500000 5.950000 0.625000 1.750000 3.750000 3.000000 2.250000 4.000000 1.250000 1.250000 2.500000 5.000000 2.100000
33 netos mexican food 2.0 3.500000 5.745000 0.905000 4.000000 4.500000 3.250000 3.500000 2.750000 2.750000 2.250000 3.375000 3.250000 3.100000
34 el nopalito 2.0 2.250000 4.870000 0.740000 3.250000 3.500000 2.000000 2.200000 3.250000 4.750000 3.000000 2.750000 3.250000 2.600000
35 los tacos 2.0 3.500000 8.200000 0.700000 3.750000 4.250000 4.250000 3.750000 2.750000 2.750000 3.500000 4.250000 4.750000 3.850000
36 albertacos 2.0 3.750000 5.475000 0.745000 3.500000 3.000000 2.900000 3.750000 2.750000 4.000000 4.000000 3.750000 4.500000 3.450000
37 el rey moro 1.0 2.800000 9.190000 0.900000 3.500000 4.500000 4.000000 3.500000 5.000000 4.500000 3.000000 3.500000 5.000000 4.000000
38 papa chito's mexican food 2.0 3.750000 6.250000 0.660000 3.750000 4.250000 2.750000 2.750000 3.250000 3.750000 3.000000 2.750000 5.000000 2.975000
39 el pueblo mexican food 1.0 4.000000 4.990000 0.670000 4.500000 4.500000 3.500000 4.000000 4.500000 5.000000 2.500000 4.500000 5.000000 4.300000
40 burros and fries 2.0 4.500000 6.890000 0.760000 3.250000 4.750000 4.000000 4.000000 3.000000 2.750000 3.500000 3.750000 4.750000 3.750000
41 king burrito 2.0 3.500000 5.140000 0.705000 2.750000 3.750000 2.500000 3.000000 2.500000 1.750000 2.750000 2.500000 4.250000 2.650000
42 carmen's mexican food 2.0 4.250000 6.500000 0.715000 3.500000 4.250000 3.500000 4.000000 4.000000 3.250000 2.750000 3.750000 4.500000 3.800000
43 senor panchos 2.0 3.250000 6.250000 0.645000 2.750000 3.750000 3.500000 3.000000 4.250000 4.500000 3.750000 3.000000 5.000000 3.450000
44 los cabos 2.0 3.500000 5.840000 0.710000 4.000000 4.500000 2.750000 3.000000 3.250000 2.500000 2.750000 4.000000 4.750000 3.500000
45 rubios ucsd 1.0 3.500000 7.990000 0.540000 1.500000 4.000000 3.000000 3.000000 1.500000 4.500000 2.500000 3.000000 1.500000 3.200000
46 lucha libre north park 28.0 3.489286 7.587500 0.827083 3.678571 3.200000 3.612000 3.364286 3.480000 3.185714 3.925926 3.314286 4.014286 3.264286

In [20]:
Ncutoff = 10
dfToRank = dfmean.loc[dfmean.N>=Ncutoff]

In [21]:
dfToRank


Out[21]:
Location N Hunger Cost Volume Tortilla Temp Meat Fillings Meat:filling Uniformity Salsa Synergy Wrap overall
4 los primos mexican food 11.0 3.318182 7.077273 0.761429 3.363636 3.500000 2.863636 3.090909 1.909091 2.750000 3.000000 2.545455 3.454545 2.645455
7 taco stand 19.0 3.078947 7.574737 0.768889 3.657895 3.289474 4.236842 3.868421 3.868421 3.789474 3.631579 4.131579 4.052632 4.063158
10 lolita's taco shop 12.0 3.141667 7.225000 0.747778 2.983333 3.275000 3.363636 3.641667 3.354545 2.991667 2.854167 3.437500 3.916667 3.283333
13 rigoberto's taco shop 11.0 3.590909 6.827273 0.890000 3.545455 3.863636 3.681818 3.590909 4.000000 3.772727 3.593750 3.818182 3.772727 3.722727
23 california burritos 19.0 3.911053 6.250000 0.823571 3.963158 3.436842 4.000000 3.947368 3.986842 3.842105 3.611111 4.052632 4.342105 4.129412
46 lucha libre north park 28.0 3.489286 7.587500 0.827083 3.678571 3.200000 3.612000 3.364286 3.480000 3.185714 3.925926 3.314286 4.014286 3.264286

In [22]:
m_Rank = ['Location','Cost','Volume','Tortilla','Temp','Meat','Fillings','Meat:filling', 'Uniformity','Salsa','Synergy','Wrap','overall']
TS = len(dfToRank)
dfRanked = pd.DataFrame(np.nan, index=range(TS), columns=m_Rank)
dfRanked.Location[:] = dfToRank.Location
for m in m_Rank[1:]:
    if m == 'Cost':
        dfRanked[m][:] = dfToRank[m].rank(ascending=1)
    else:
        dfRanked[m][:] = dfToRank[m].rank(ascending=0)


C:\Users\Scott\Anaconda2\lib\site-packages\ipykernel\__main__.py:7: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
C:\Users\Scott\Anaconda2\lib\site-packages\ipykernel\__main__.py:9: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy

In [23]:
dfRanked


Out[23]:
Location Cost Volume Tortilla Temp Meat Fillings Meat:filling Uniformity Salsa Synergy Wrap overall
0 los primos mexican food 3.0 5.0 5.0 2.0 6.0 6.0 6.0 6.0 5.0 6.0 6.0 6.0
1 taco stand 5.0 4.0 3.0 4.0 1.0 2.0 3.0 2.0 2.0 1.0 2.0 2.0
2 lolita's taco shop 4.0 6.0 6.0 5.0 5.0 3.0 5.0 5.0 6.0 4.0 4.0 4.0
3 rigoberto's taco shop 2.0 1.0 4.0 1.0 3.0 4.0 1.0 3.0 4.0 3.0 5.0 3.0
4 california burritos 1.0 3.0 1.0 3.0 2.0 1.0 2.0 1.0 3.0 2.0 1.0 1.0
5 lucha libre north park 6.0 2.0 2.0 6.0 4.0 5.0 4.0 4.0 1.0 5.0 3.0 5.0

In [37]:
dfRanked.loc[0].overall


Out[37]:
6.0

In [44]:
rank_strs = {}
Nrank = len(dfRanked)
for k in dfRanked.keys()[1:]:
    rank_strs[k] = ['']*Nrank
    for i in range(Nrank):
        rest_rank = dfRanked.loc[i][k]-1
        rank_strs[k][int(rest_rank)] = dfRanked.loc[i].Location

In [55]:
dfRank2 = pd.DataFrame(index=np.arange(1,1+Nrank),columns=rank_strs.keys())
for k in dfRank2.keys():
    dfRank2[k] = rank_strs[k]

In [56]:
dfRank2


Out[56]:
Synergy Fillings Meat Temp overall Meat:filling Volume Wrap Cost Uniformity Salsa Tortilla
1 taco stand california burritos taco stand rigoberto's taco shop california burritos rigoberto's taco shop rigoberto's taco shop california burritos california burritos california burritos lucha libre north park california burritos
2 california burritos taco stand california burritos los primos mexican food taco stand california burritos lucha libre north park taco stand rigoberto's taco shop taco stand taco stand lucha libre north park
3 rigoberto's taco shop lolita's taco shop rigoberto's taco shop california burritos rigoberto's taco shop taco stand california burritos lucha libre north park los primos mexican food rigoberto's taco shop california burritos taco stand
4 lolita's taco shop rigoberto's taco shop lucha libre north park taco stand lolita's taco shop lucha libre north park taco stand lolita's taco shop lolita's taco shop lucha libre north park rigoberto's taco shop rigoberto's taco shop
5 lucha libre north park lucha libre north park lolita's taco shop lolita's taco shop lucha libre north park lolita's taco shop los primos mexican food rigoberto's taco shop taco stand lolita's taco shop los primos mexican food los primos mexican food
6 los primos mexican food los primos mexican food los primos mexican food lucha libre north park los primos mexican food los primos mexican food lolita's taco shop los primos mexican food lucha libre north park los primos mexican food lolita's taco shop lolita's taco shop

In [60]:
dfRank2.reindex_axis(['Salsa','Volume','Meat','overall','Cost','Temp'], axis=1)


Out[60]:
Salsa Volume Meat overall Cost Temp
1 lucha libre north park rigoberto's taco shop taco stand california burritos california burritos rigoberto's taco shop
2 taco stand lucha libre north park california burritos taco stand rigoberto's taco shop los primos mexican food
3 california burritos california burritos rigoberto's taco shop rigoberto's taco shop los primos mexican food california burritos
4 rigoberto's taco shop taco stand lucha libre north park lolita's taco shop lolita's taco shop taco stand
5 los primos mexican food los primos mexican food lolita's taco shop lucha libre north park taco stand lolita's taco shop
6 lolita's taco shop lolita's taco shop los primos mexican food los primos mexican food lucha libre north park lucha libre north park

California vs. noncalifornia


In [26]:
# Number of each type of burrito
import re
re4str = re.compile('.*Cali.*', re.IGNORECASE)
N = len(dfLuchaLibre)
iscali = np.zeros(N,dtype=bool)
for i, b in enumerate(dfLuchaLibre.Burrito):
    if re4str.match(b):
        iscali[i] = True
    else:
        iscali[i] = False

In [29]:
dfLuchaLibre.iscali = iscali

In [34]:
sp.stats.ttest_ind(dfLuchaLibre[dfLuchaLibre.iscali==True].overall,dfLuchaLibre[dfLuchaLibre.iscali==False].overall)


Out[34]:
Ttest_indResult(statistic=nan, pvalue=nan)

In [ ]: