def event_counts_date(request_disc=None):
    '''
    Plot the average timeline of a certain institution
    request should be given as a dictionary
    '''
    request = np.ones(df.shape[0], dtype=bool)
    for key in request_disc.keys():
        if key == "institution":
            request = request & (df[key].str.contains(request_disc[key]))
        else:
            request = request & (df[key] == request_disc[key])
    df_selected = df[request]
    df_selected["date_md"] = df_selected["admission_date"].apply(
        lambda dt: dt.replace(year=1980))
    df_selected["year"] = df_selected["admission_date"].apply(
        lambda dt: dt.year)

    samp = df[request].iloc[0]
    title = ""
    for key in request_disc.keys():
        title += samp[key]
        title += " "
    gg = p9.ggplot(df_selected)
    gg += p9.aes(x="date_md", y="admission_status")
    gg += p9.scale_x_datetime(date_breaks='10 days',
                              date_labels="%m-%d",
                              limits=np.array([
                                  np.min(df_selected["date_md"]),
                                  pd.to_datetime("1980-4-20")
                              ]))
    gg += p9.geom_count()
    gg += p9.ggtitle(title)
    return gg
Пример #2
0
def test_continuous_x_y():
    p = ggplot(df, aes('y', 'y')) + geom_count()

    assert p + _theme == 'continuous_x_y'
Пример #3
0
def test_continuous_x_y():
    p = ggplot(df, aes('y', 'y')) + geom_count()

    assert p + _theme == 'continuous_x_y'
Пример #4
0
def test_discrete_y():
    p = ggplot(df, aes('y', 'x')) + geom_count()

    assert p + _theme == 'discrete_y'
Пример #5
0
def test_discrete_y():
    p = ggplot(df, aes('y', 'x')) + geom_count()

    assert p + _theme == 'discrete_y'