In [1]:
import pandas as pd
import plotly.plotly as py
import plotly.figure_factory as ff
import json
with open("/Users/Alan/.plotly/.credentials", 'rb') as fi:
    cred= json.load(fi, encoding='utf-8')
myapi = cred['api_key']
username = cred['username']
py.sign_in(username, myapi)

Area Index

  • TOR: 3
  • PHO: 2
  • LAS: 7

In [2]:
b = pd.read_pickle("../yelp-challenge/data_all_cities/all_cities_preprocess.pkl")
area = pd.read_pickle("../yelp-challenge/data_processeing/spatial_labels.pkl")
TOR = area[area.spatial_label == 3]
PHO = area[area.spatial_label == 2]
LAS = area[area.spatial_label == 7]



By # of Business_ID


The Greater Torronto Area


In [10]:
Tcity = b[['city']].join(TOR, how='inner').city.value_counts().keys().values[:4]

In [11]:
map(str,Tcity)


Out[11]:
['Toronto', 'Mississauga', 'Markham', 'Vaughan']

The Greater Phoenix Area


In [12]:
Pcity = b[['city']].join(PHO, how='inner').city.value_counts().keys().values[:4]

In [13]:
map(str, Pcity)


Out[13]:
['Phoenix', 'Scottsdale', 'Mesa', 'Tempe']

The Greater Las Vegas Area


In [14]:
Lcity =b[['city']].join(LAS, how='inner').city.value_counts().keys().values[:4]

In [15]:
map(str, Lcity)


Out[15]:
['Las Vegas', 'Henderson', 'North Las Vegas', 'Boulder City']

PLOT


In [18]:
data_matrix = [['Area', 'City1', 'City2', 'City3', 'City4', '...'],
               ['The Greater \nTorronto Area', 'Toronto', 'Mississauga', 'Markham', 'Vaughan', '...'],
               ['The Greater \nPhoenix Area', 'Phoenix', 'Scottsdale', 'Mesa', 'Tempe', '...'],
               ['The Greater \nLas Vegas Area', 'Las Vegas', 'Henderson', 'North Las Vegas', 'Boulder City', '...']]

table = ff.create_table(data_matrix)
py.iplot(table, filename='simple_table')


Out[18]: