Example #1
0
def test_create_example_1():
    """Create a dashboard contain using chinese population data in the past 15 years"""
    home_resource = home.Home()
    dash_resource = dash.DashData()

    # get and store population data
    url = 'https://github.com/litaotao/IPython-Dashboard/raw/master/docs/people_number_by_province_lateset_10_years.csv'
    if os.path.isdir(TMP_DIR) and  'people_number_by_province_lateset_10_years.csv' in os.listdir(TMP_DIR):
        url = TMP_DIR + '/people_number_by_province_lateset_10_years.csv'
    value = pd.read_csv(url)
    sender(value, 'chinese_population', value.to_json())

    # create sample dashboard
    dash_id, meta, content, = home_resource._create_dash("Dash: Chinese Population", "that man")
    data = TEST_DASH_DATA.get('example_chinese_population')
    dash_resource._update_dash(dash_id, data)
def test_create_dataframe():
    url = 'https://github.com/litaotao/data-science/raw/master/examples/happy-healthy-hungry/data/SFBusinesses/businesses.csv'
    if os.path.isdir(TMP_DIR) and 'businesses.csv' in os.listdir(TMP_DIR):
        url = TMP_DIR + '/businesses.csv'
    data = pd.read_csv(url)
    piece_lenth = 1000
    for piece in range(len(data) / piece_lenth):
        key = 'businesses-{}'.format(piece)
        value = data[piece * piece_lenth : piece * piece_lenth + piece_lenth]
        # r_kv.set(key, value.to_json())
        sender(value, key, value.to_json())

    url_2 = 'https://github.com/litaotao/data-science/raw/master/examples/happy-healthy-hungry/data/SFBusinesses/inspections.csv'
    if os.path.isdir(TMP_DIR) and  'inspections.csv' in os.listdir(TMP_DIR):
        url_2 = TMP_DIR + '/inspections.csv'
    data = pd.read_csv(url_2)
    piece_lenth = 1000
    for piece in range(len(data) / piece_lenth):
        key = 'inspections-{}'.format(piece)
        value = data[piece * piece_lenth : piece * piece_lenth + piece_lenth]
        # r_kv.set(key, value.to_json())
        sender(value, key, value.to_json())
    #
    url_3 = 'https://github.com/litaotao/IPython-Dashboard/raw/v-0.1.2-visualiza-table/docs/people_number_by_province_lateset_10_years.csv'
    if os.path.isdir(TMP_DIR) and  'people_number_by_province_lateset_10_years.csv' in os.listdir(TMP_DIR):
        url_3 = TMP_DIR + '/people_number_by_province_lateset_10_years.csv'
    value = pd.read_csv(url_3)
    # r_kv.set('chinese_population', value.to_json())
    sender(value, 'chinese_population', value.to_json())
def test_create_dataframe():
    url = 'https://github.com/litaotao/data-science/raw/master/examples/happy-healthy-hungry/data/SFBusinesses/businesses.csv'
    if os.path.isdir(TMP_DIR) and 'businesses.csv' in os.listdir(TMP_DIR):
        url = TMP_DIR + '/businesses.csv'
    data = pd.read_csv(url)
    piece_lenth = 1000
    for piece in range(len(data) / piece_lenth):
        key = 'businesses-{}'.format(piece)
        value = data[piece * piece_lenth:piece * piece_lenth + piece_lenth]
        # r_kv.set(key, value.to_json())
        sender(value, key, value.to_json())

    url_2 = 'https://github.com/litaotao/data-science/raw/master/examples/happy-healthy-hungry/data/SFBusinesses/inspections.csv'
    if os.path.isdir(TMP_DIR) and 'inspections.csv' in os.listdir(TMP_DIR):
        url_2 = TMP_DIR + '/inspections.csv'
    data = pd.read_csv(url_2)
    piece_lenth = 1000
    for piece in range(len(data) / piece_lenth):
        key = 'inspections-{}'.format(piece)
        value = data[piece * piece_lenth:piece * piece_lenth + piece_lenth]
        # r_kv.set(key, value.to_json())
        sender(value, key, value.to_json())
    #
    url_3 = 'https://github.com/litaotao/IPython-Dashboard/raw/v-0.1.2-visualiza-table/docs/people_number_by_province_lateset_10_years.csv'
    if os.path.isdir(
            TMP_DIR
    ) and 'people_number_by_province_lateset_10_years.csv' in os.listdir(
            TMP_DIR):
        url_3 = TMP_DIR + '/people_number_by_province_lateset_10_years.csv'
    value = pd.read_csv(url_3)
    # r_kv.set('chinese_population', value.to_json())
    sender(value, 'chinese_population', value.to_json())