Пример #1
0
def make_jhu_country_cases_chart(override_props) -> CovidChart:
    jhu_df = pd.read_csv('./data/jhu-data.csv')
    jhu_df = jhu_df[(jhu_df.Province_State.isnull()) & (jhu_df.Country_Region != 'China')]

    #qcsv = './data/quarantine-activity-Apr19.csv'
    qcsv = './data/quarantine-activity-world-new-export.csv'
    
    days_since = 50
    groupcol = 'Country_Region'
    chart = CovidChart(
        jhu_df,
        groupcol=groupcol,
        start_criterion=DaysSinceNumReached(days_since, 'Confirmed'),
        ycol='Confirmed',
        level='country',
        xcol='Date',
        top_k_groups=30,
        sample_every=3,
        quarantine_df=qcsv
    )


    # chart.set_colormap()
    chart.set_unfocused_opacity(0.05)
    chart = chart.set_ytitle('Number of Confirmed Cases (log scale)')
    chart = chart.set_xtitle(['Days since {} Confirmed'.format(days_since), '(Events prior to Day 0 not shown)'])
    chart.set_width(600).set_height(400)
    chart.set_ydomain((days_since, 1000000))
    chart.set_xdomain((0, 72 + EXTRA_DAYS_TO_INCLUDE))
    chart.click_selection_init = first_alphabetic_group(chart._preprocess_df(), groupcol)
    chart = _maybe_add_staging_props(chart)
    chart.spec.update(override_props)
    return chart
Пример #2
0
def make_jhu_country_deaths_chart(override_props) -> CovidChart:
    jhu_df = pd.read_csv("./data/jhu-data.csv")
    jhu_df = jhu_df.loc[(jhu_df.Country_Region != 'China') & jhu_df.Province_State.isnull()]

    qcsv = './data/quarantine-activity-Apr19.csv'

    days_since = 10
    groupcol = 'Country_Region'
    chart = CovidChart(
        jhu_df,
        groupcol=groupcol,
        start_criterion=DaysSinceNumReached(days_since, 'Deaths'),
        ycol='Deaths',
        xcol='Date',
        level='country',
        top_k_groups=30,
        sample_every=3,
        quarantine_df=qcsv
    )

    chart = chart.set_ytitle('Number of Deaths (log scale)')
    chart = chart.set_xtitle(['Days since {} Deaths'.format(days_since),'(Events prior to Day 0 not shown)'])
    chart.set_width(600).set_height(400)
    chart.set_ydomain((days_since, 100000))
    chart.set_xdomain((0, 62 + EXTRA_DAYS_TO_INCLUDE))
    chart.click_selection_init = first_alphabetic_group(chart._preprocess_df(), groupcol)
    chart = _maybe_add_staging_props(chart)
    chart.spec.update(override_props)
    return chart
Пример #3
0
def make_jhu_state_deaths_chart(override_props) -> CovidChart:
    jhu_df = pd.read_csv('./data/jhu-data.csv')
    jhu_df = jhu_df.loc[(jhu_df.Country_Region == 'United States') & jhu_df.Province_State.notnull()]

    if STAGING:
        level = 'usa'
        #qcsv = './data/quarantine-activity-US-Apr16.csv'
        qcsv = './data/combined-activity-US-Jun9.csv'
    else:
        level = 'usa_old'
        qcsv = './data/quarantine-activity-US.csv'

    days_since = 10
    groupcol = 'Province_State'
    chart = CovidChart(
        jhu_df,
        groupcol=groupcol,
        start_criterion=DaysSinceNumReached(days_since, 'Deaths'),
        ycol='Deaths',
        xcol='Date',
        level=level,
        top_k_groups=30,
        sample_every=3,
        quarantine_df=qcsv  # should have a column with same name as `groupcol`
    )

    chart = chart.set_ytitle('Number of Deaths (log scale)')
    chart = chart.set_xtitle(['Days since {} Deaths'.format(days_since), '(Events prior to Day 0 not shown)'])
    chart.set_width(600).set_height(400)
    chart.set_ydomain((days_since, 100000))
    chart.set_xdomain((0, 47 + EXTRA_DAYS_TO_INCLUDE))
    chart.click_selection_init = first_alphabetic_group(chart._preprocess_df(), groupcol)
    chart = _maybe_add_staging_props(chart)
    chart.spec.update(override_props)
    return chart
Пример #4
0
def make_jhu_state_cases_chart(override_props) -> CovidChart:
    jhu_df = pd.read_csv('./data/jhu-data.csv')
    # grab us-specific
    jhu_df = jhu_df[(jhu_df.Country_Region == 'United States')
                    & jhu_df.Province_State.notnull()]

    if STAGING:
        level = 'usa'
        qcsv = './data/quarantine-activity-US-Apr16.csv'
    else:
        level = 'usa_old'
        qcsv = './data/quarantine-activity-US.csv'

    days_since = 20
    groupcol = 'Province_State'
    chart = CovidChart(
        jhu_df,
        groupcol=groupcol,
        start_criterion=DaysSinceNumReached(days_since, 'Confirmed'),
        ycol='Confirmed',
        level=level,
        xcol='Date',
        top_k_groups=30,
        quarantine_df=qcsv  # should have a column with same name as `groupcol`
    )
    # chart.set_colormap()
    chart.set_unfocused_opacity(0.05)
    chart = chart.set_ytitle('Number of Confirmed Cases (log scale)')
    chart = chart.set_xtitle([
        'Days since {} Confirmed'.format(days_since),
        '(Events prior to Day 0 not shown)'
    ])
    chart.set_width(600).set_height(400)
    chart.set_xdomain((0, 47 + EXTRA_DAYS_TO_INCLUDE)).set_ydomain(
        (days_since, 200000))
    chart.click_selection_init = first_alphabetic_group(
        chart._preprocess_df(), groupcol)
    chart = _maybe_add_staging_props(chart)
    chart.spec.update(override_props)
    return chart