Пример #1
0
no_negs[no_negs < 0] = 0

rolling = no_negs.rolling(7).mean()
rolling.to_csv("rolling.csv")
lga_movement = []

for col in totals.index:
	print(col)
	row = {}
	row['lga'] = col
	row['change'] = rolling.loc[lga_daily.index[-1], col] - rolling.loc[one_week_ago, col]
	row['this_week'] = lga_daily[one_week_ago:][col].sum()
	row['last_week'] = lga_daily[two_weeks_ago:one_week_ago - timedelta(days=1)][col].sum()
	row['weekly_change'] = 	row['this_week'] - row['last_week']
	row['date'] = lga_daily.index[-1].strftime('%Y-%m-%d')
	lga_movement.append(row)

lga_df_movement1 = pd.DataFrame(lga_movement)


#%%

syncData(lga_movement,'2020/07/vic-corona-map{test}'.format(test=test), "vicChange-2")
	
syncData(totals_30day.to_dict(orient='records'),'2020/07/vic-corona-map{test}'.format(test=test), "vicTotals")

# short['rolling_mean'] = df.groupby('lga')['cases'].transform(lambda x: x.rolling(7, 1).mean())


Пример #2
0
negative_countries_deaths = []

for country in deaths_countries:
    temp_series = deaths_new[deaths_new[country] < 0]
    if len(temp_series.index) > 0:
        negative_countries_deaths.append(country)

print(",".join(negative_countries_deaths))

deaths_new[deaths_new < 0] = 0

#%%

confirmedDailyData = json.dumps(ecdc_new.reset_index().to_dict('records'))
syncData(confirmedDailyData, "2020/03/coronavirus-widget-data",
         "confirmed_daily_ecdc.json")

confirmedTotalData = json.dumps(ecdc_high.reset_index().to_dict('records'))
syncData(confirmedTotalData, "2020/03/coronavirus-widget-data",
         "confirmed_total_ecdc.json")

negativeCaseData = json.dumps(negative_cases)
syncData(negativeCaseData, "2020/03/coronavirus-widget-data",
         "negative_case_countries.json")

#%%

confirmedDailyDeathData = json.dumps(
    deaths_new.reset_index().to_dict('records'))
syncData(confirmedDailyDeathData, "2020/03/coronavirus-widget-data",
         "confirmed_daily_deaths_ecdc.json")
Пример #3
0
with open('latest.json') as json_file:
    latestJson = json.load(json_file)
    latestObj = []
    shortlist = ["Australia", "United Kingdom", "US"]

    for row in latestJson['features']:
        latestObj.append(row['attributes'])

    latest = pd.DataFrame(latestObj)

    latest_country = latest.groupby(["Country_Region"]).sum()
    latest_country.loc['Total'] = latest_country.sum()

    latestData = json.dumps(latest_country.reset_index().to_dict('records'))

    syncData(latestData, "2020/03/coronavirus-widget-data",
             "latest{preview}.json".format(preview=preview))

# For confirmed cases, since we want it for charts

confirmed = pd.read_csv("time_series_covid19_confirmed_global.csv")

shortlist = ["United Kingdom", "US", "Total"]

confirmed.loc['Total'] = confirmed.sum(numeric_only=True, axis=0)

confirmed.loc[['Total'], ["Country/Region"]] = "Total"

confirmed_country = confirmed.groupby(["Country/Region"]).sum()

over100 = confirmed_country[confirmed_country.iloc[:, -1] > 100]
Пример #4
0
                data['notes'] = notes

        #handle weird cases

        if data['entry'] != "":

            if data['notes'] == "German literary movement":
                data['entry'] = "Sturm und Drang"

            #print data
            styleData.append(data)

final = {"data": styleData, "lastUpdated": currDate + " " + currTime}

if not errors:
    syncData(json.dumps(final, indent=4), "australia/2014/styleguide",
             "style-guide.json")

with open('style-guide.json', 'w') as f:
    json.dump(final, f, indent=4)

# output = StringIO.StringIO()
# output.write('{"data":')
# output.write(json.dumps(styleData))
# output.write(', "lastUpdated":"' + currDate + ' ' + currTime + '"')
# output.write('}')

# print "Connecting to S3"

# bucket = conn.get_bucket('gdn-cdn')

# from boto.s3.key import Key
Пример #5
0
headers = {
    'User-Agent':
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'
}
r = requests.get('https://covidlive.com.au/covid-live.json', headers=headers)

#%%

data = r.json()

df = pd.read_json(r.text)

print(list(df.columns.values))

cols = [
    'REPORT_DATE', 'LAST_UPDATED_DATE', 'ACTIVE_CNT', 'PREV_ACTIVE_CNT',
    'CODE', 'NAME', 'RECOV_CNT', 'VACC_DIST_CNT', 'PREV_VACC_DIST_CNT',
    'VACC_DOSE_CNT', 'PREV_VACC_DOSE_CNT', 'VACC_PEOPLE_CNT',
    'PREV_VACC_PEOPLE_CNT'
]

df_aus = df[df['NAME'] == "Australia"]
df_aus = df_aus[df_aus['REPORT_DATE'] >= '2021-02-14']

final = df_aus[cols]
finalJson = final.to_json(orient='records')

#%%

syncData(finalJson, "2021/02/coronavirus-widget-data", "aus-vaccines.json")
Пример #6
0
no_negs = lga_daily

no_negs[no_negs < 0] = 0

rolling = no_negs.rolling(7).mean()
rolling.to_csv("rolling.csv")
lga_movement = []

for col in totals.index:
	print(col)
	row = {}
	row['lga'] = col
	row['change'] = rolling.loc[lga_daily.index[-1], col] - rolling.loc[one_week_ago, col]
	row['this_week'] = lga_daily[one_week_ago:][col].sum()
	row['last_week'] = lga_daily[two_weeks_ago:one_week_ago - timedelta(days=1)][col].sum()
	row['weekly_change'] = 	row['this_week'] - row['last_week']
	row['date'] = lga_daily.index[-1].strftime('%Y-%m-%d')
	lga_movement.append(row)

lga_df_movement1 = pd.DataFrame(lga_movement)


#%%

syncData(lga_movement,'2020/07/vic-corona-map{test}'.format(test=test), "vicChange-2")
	
# short['rolling_mean'] = df.groupby('lga')['cases'].transform(lambda x: x.rolling(7, 1).mean())