Esempio n. 1
0
def api9_detail():

    country = request.args.get('country')

    recovered = data.getRecovered()
    recovered = recovered[recovered['Country/Region'] == country]
    if len(recovered.index) == 0:
        abort(404)
    recovered = recovered.iloc[:,4:]
    total = recovered.sum(axis=0)
    labels = total.index[1:].values.tolist()
    new_recovered = np.nan_to_num(total.values[1:] - total.values[:-1]).tolist()

    return {
        'labels': labels,
        'new_recovered': new_recovered,
    }
Esempio n. 2
0
def vn_linechart02():

    country = 'Vietnam'
    
    recovered = data.getRecovered()
    recovered = recovered[recovered['Country/Region'] == country]
    recovered = recovered.iloc[:,4:]
    recovered = recovered.sum(axis=0).values

    death = data.getDeath()
    death = death[death['Country/Region'] == country]
    death = death.iloc[:,4:]
    death = death.sum(axis=0).values

    return {
        'Death': np.nan_to_num(death).tolist(),
        'Recovered': np.nan_to_num(recovered).tolist()
    }
Esempio n. 3
0
def api2():
    confirmed = data.getConfirmed()
    confirmed = pd.concat([confirmed.iloc[:,:4], confirmed.iloc[:,-1].rename('cases')], axis=1)
    confirmed['country'] = confirmed.apply(lambda a: a['Country/Region'] if isinstance(a['Province/State'], float)
            else a['Province/State'] +', ' + a['Country/Region'], axis=1)
    
    recovered = data.getRecovered().iloc[:,-1].rename('recovered')
    
    death = data.getDeath().iloc[:,-1].rename('deaths')
    
    result = pd.concat([confirmed, recovered, death], axis=1)
    result[['recovered', 'deaths']] = result[['recovered', 'deaths']].fillna(0)

    result = result.rename(columns={"Lat": "lat", "Long": "lon"})
    
    result = result.drop(['Province/State', 'Country/Region'], axis=1)

    result = result.to_dict('record')

    return jsonify(result)
Esempio n. 4
0
def api4():

    confirmed = data.getConfirmed()
    confirmed = confirmed.iloc[:,4:]

    date = confirmed.columns
    confirmed = confirmed.sum(axis=0).values

    recovered = data.getRecovered()
    recovered = recovered.iloc[:,4:]
    recovered = recovered.sum(axis=0).values

    death = data.getDeath()
    death = death.iloc[:,4:]
    death = death.sum(axis=0).values

    return {
        'date': np.nan_to_num(date).tolist(),
        'cases': np.nan_to_num(confirmed).tolist(),
        'deaths': np.nan_to_num(death).tolist(),
        'recovered': np.nan_to_num(recovered).tolist()
    }
Esempio n. 5
0
def api1():
    confirmed = data.getConfirmed()
    latest_confirmed = confirmed.iloc[:,-1]
    total_confirmed = int(latest_confirmed.sum())

    recovered = data.getRecovered()
    latest_recovered = recovered.iloc[:,-1]
    total_recovered = int(latest_recovered.sum())

    death = data.getDeath()
    latest_death = death.iloc[:,-1]
    total_death = int(latest_death.sum())

    death_rate = round(total_death / total_confirmed, 4)
    recover_rate = round(total_recovered / total_confirmed, 4)

    return {
        'cases': total_confirmed,
        'deaths': total_death,
        'recovered': total_recovered,
        'death_rate': death_rate,
        'recovered_rate': recover_rate
    }