コード例 #1
0
ファイル: build-charts.py プロジェクト: covidvis/covid19-vis
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
ファイル: build-charts.py プロジェクト: covidvis/covid19-vis
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
コード例 #3
0
ファイル: build-charts.py プロジェクト: covidvis/covid19-vis
def make_jhu_selected_state_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()]
    # jhu_df[(nyt_df["state"]=="Illinois")|(nyt_df["state"]=="New York")| (nyt_df["state"]=="New Jersey")| (nyt_df["state"]=="Washington")| (nyt_df["state"]=="Michigan")]
    days_since = 20
    chart = CovidChart(
        jhu_df,
        groupcol='Province_State',
        start_criterion=DaysSinceNumReached(days_since, 'Confirmed'),
        ycol='Confirmed',
        level='USA',
        xcol='Date',
        top_k_groups=20,
        quarantine_df = './data/combined-activity-US-Jun9.csv'
        #quarantine_df='./data/quarantine-activity-US.csv'  # 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(250).set_height(400)
    chart.set_xdomain((0, 35)).set_ydomain((days_since, 100000))
    chart.set_title("States With Significant Rate Decreases")
    chart = _maybe_add_staging_props(chart)
    chart.spec.update(override_props)
    return chart
コード例 #4
0
ファイル: build-charts.py プロジェクト: covidvis/covid19-vis
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
コード例 #5
0
def make_jhu_country_chart() -> CovidChart:
    jhu_df = pd.read_csv('./data/jhu-data.csv')
    jhu_df = jhu_df[(jhu_df.Province_State.isnull())
                    & (jhu_df.Country_Region != 'China')]

    days_since = 50
    chart = CovidChart(
        jhu_df,
        groupcol='Country_Region',
        start_criterion=DaysSinceNumReached(days_since, 'Confirmed'),
        ycol='Confirmed',
        chart_type='country',
        xcol='Date',
        top_k_groups=20,
        quarantine_df=
        './data/quarantine-activity.csv'  # 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)')
    chart = chart.set_xtitle('Days since {} Confirmed'.format(days_since))
    chart.set_width(600).set_height(400)
    chart.set_ydomain((days_since, 200000))
    chart.set_xdomain((0, 40))
    return chart
コード例 #6
0
def make_jhu_state_chart() -> 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()]

    days_since = 20
    chart = CovidChart(
        jhu_df,
        groupcol='Province_State',
        start_criterion=DaysSinceNumReached(days_since, 'Confirmed'),
        ycol='Confirmed',
        chart_type='USA',
        xcol='Date',
        top_k_groups=20,
        quarantine_df=
        './data/quarantine-activity-US.csv'  # 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)')
    chart = chart.set_xtitle('Days since {} Confirmed'.format(days_since))
    chart.set_width(600).set_height(400)
    chart.set_xdomain((0, 30)).set_ydomain((days_since, 100000))
    return chart
コード例 #7
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
コード例 #8
0
def make_jhu_state_death_chart() -> 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()]

    chart = CovidChart(
        jhu_df,
        groupcol='Province_State',
        start_criterion=DaysSinceNumReached(10, 'Deaths'),
        ycol='Deaths',
        xcol='Date',
        chart_type='usa',
        top_k_groups=20,
        quarantine_df=
        './data/quarantine-activity-us.csv'  # should have a column with same name as `groupcol`
    )

    chart = chart.set_ytitle('Number of Deaths (log)')
    chart = chart.set_xtitle('Days since 10 Deaths')
    chart.set_width(600).set_height(400)
    chart.set_ydomain((10, 10000))
    chart.set_xdomain((0, 25)).compile()
    return chart