Ejemplo n.º 1
0
def get_top_countries(args, df):
    df = df.replace({'United Kingdom': 'UK'}, regex=True)
    df1 = df.copy()
    df1 = date_normalize(df1)
    df1 = df1.sort_values(by='date')
    last_date = df1.tail(1)['date'].values[0]
    df_last = df1[df1['date'] == last_date]
    #df_last = df_last.sort_values(by=['confirmed'],ascending=False)[:50]
    df_last = df_last.sort_values(by=['deaths'], ascending=False)[:50]

    df_last.to_csv(args.output_dir + "top_countries.csv",
                   columns=['country', 'confirmed', 'deaths', 'recovered'],
                   index=False)

    fig = plt.figure(figsize=(36, 24))
    ax = fig.add_subplot(111)

    df_last.plot(x="country", y="confirmed", kind="bar", ax=ax, color="C1")
    df_last.plot(x="country", y="recovered", kind="bar", ax=ax, color="C2")
    df_last.plot(x="country", y="deaths", kind="bar", ax=ax, color="C3")
    ax.set_yscale('log')
    ax.set_ylabel('log')
    ax.set_title("Covid-19:" + str(date.today()))
    plt.setp(ax.get_xticklabels(),
             rotation=45,
             horizontalalignment='right',
             fontsize=10)
    ax.grid()

    fig.text(0.65, 0.25, 'By Jayanti Prasad',fontsize=50, color='gray',\
         ha='right', va='bottom', alpha=0.5)

    plt.savefig(args.output_dir + os.sep + "top_countries0.pdf")
    plt.show()
Ejemplo n.º 2
0
def get_top_countries(df, count):
    df = df.replace({'United Kingdom': 'UK'}, regex=True)
    df1 = df.copy()
    df1 = date_normalize(df1)
    df1 = df1.sort_values(by='date')
    last_date = df1.tail(1)['date'].values[0]
    df_top = df1[df1['date'] == last_date]
    df_top = df_top.sort_values(by=['confirmed'], ascending=False)[:count]

    return df_top
Ejemplo n.º 3
0
                        default='2020-03-01')
    parser.add_argument('-n',
                        '--num-days',
                        help='Number of days',
                        type=int,
                        default=160)
    parser.add_argument('-b', '--beta', help='Beta', type=float, default=0.21)
    parser.add_argument('-g', '--gamma', help='Gamma', type=float, default=0.1)

    args = parser.parse_args()

    start_date = args.start_date
    print("starting date:", start_date)

    df = pd.read_csv(args.input_file)
    df = date_normalize(df)
    df = df.sort_values(by='date')

    data = get_country_data(df, args.country_name, args.start_date)
    xx = [i for i in range(0, len(data))]
    print("I0=", data[start_date])

    N, I0, R0 = 6.0E8, float(data[start_date]), 0

    L = Learner(args, df, loss, N, I0, R0)
    beta, gamma = L.fit()

    print("beta=", beta, "gamma=", gamma, "I0=", I0, "data size=", len(data))

    new_indx, predict, sir = L.predict(beta, gamma, data, args.num_days)
    #sir  = solve_ode (args.beta, args.gamma, args.num_days, N,I0, R0)