示例#1
0
def visualize(zipcode):
    response = ''
    if data is not None:
        response = createChart(data, zipcode).to_json()

    return Response(response,
                    mimetype='application/json',
                    headers={
                        'Cache-Control': 'no-cache',
                        'Access-Control-Allow-Origin': '*'
                    })
示例#2
0
def visualize(platform, rating):
    df = data.get(platform, None)
    response = ''
    if df is not None:
        #response = showTopWords(df[df.rating==rating]['content']).to_json()
        response = createChart(df[['name', 'rating']], platform).to_json()

    return Response(response,
        mimetype='application/json',
        headers={
            'Cache-Control': 'no-cache',
            'Access-Control-Allow-Origin': '*'
        }
    )
示例#3
0
def visualize(zip):
    df = data
    RestFilter = df[['cuisine','perZip.' + zip]]
    RestFilter.rename(columns={'perZip.' + zip: 'total'}, inplace=True)
    RestFilter = RestFilter.dropna(axis=0, how='any')
    RestFilter = RestFilter.sort_values(by=['total'], ascending=False)[['cuisine', 'total']]
    response = ''
    if RestFilter is not None:
        response = createChart(RestFilter, zip).to_json()

    return Response(response,
        mimetype='application/json',
        headers={
            'Cache-Control': 'no-cache',
            'Access-Control-Allow-Origin': '*'
        }
    )
示例#4
0
文件: app.py 项目: bh1555/dataviz
def visualize(platform):
    df = data.get(platform, None)
    response = ''
    # if df is not None:
    #     response = createChart(df[['name', 'rating']], platform).to_json()

    zipcode_list = ['total', '10001', '10002', '10003', '10004', '10005', '10006', '10007', '10009', '10010', '10011', '10012', '10013', '10014', '10016', '10017', '10018', '10019', '10020', '10021', '10022', '10023', '10024', '10025', '10026', '10027', '10028', '10029', '10030', '10031', '10032', '10033', '10034', '10035', '10036', '10037', '10038', '10039', '10040', '10044', '10048', '10057', '10065', '10069', '10075', '10104', '10105', '10106', '10111', '10112', '10118', '10119', '10121', '10128', '10152', '10153', '10155', '10165', '10167', '10168', '10169', '10171', '10176', '10178', '10179', '10199', '10271', '10279', '10280', '10281', '10282', '10285', '10301', '10302', '10303', '10304', '10305', '10306', '10307', '10308', '10309', '10310', '10311', '10312', '10314', '10451', '10452', '10453', '10454', '10455', '10456', '10457', '10458', '10459', '10460', '10461', '10462', '10463', '10464', '10465', '10466', '10467', '10468', '10469', '10470', '10471', '10472', '10473', '10474', '10475', '11001', '11004', '11005', '11040', '11101', '11102', '11103', '11104', '11105', '11106', '11109', '11201', '11203', '11204', '11205', '11206', '11207', '11208', '11209', '11210', '11211', '11212', '11213', '11214', '11215', '11216', '11217', '11218', '11219', '11220', '11221', '11222', '11223', '11224', '11225', '11226', '11228', '11229', '11230', '11231', '11232', '11233', '11234', '11235', '11236', '11237', '11238', '11239', '11245', '11249', '11256', '11354', '11355', '11356', '11357', '11358', '11360', '11361', '11362', '11363', '11364', '11365', '11366', '11367', '11368', '11369', '11370', '11371', '11372', '11373', '11374', '11375', '11377', '11378', '11379', '11385', '11412', '11413', '11414', '11415', '11416', '11417', '11418', '11419', '11420', '11421', '11422', '11423', '11426', '11427', '11428', '11429', '11430', '11432', '11433', '11434', '11435', '11436', '11451', '11691', '11693', '11694', '11697']

    if platform in zipcode_list:
        response = createChart(df[['name', 'rating']], platform).to_json()
    else:
        response = createFakeChart(df[['name', 'rating']], platform).to_json()



    return Response(response,
        mimetype='application/json',
        headers={
            'Cache-Control': 'no-cache',
            'Access-Control-Allow-Origin': '*'
        }
    )