in processing-pipelines/bigquery/chart-creator/python/app.py [0:0]
def query_covid_dataset(country, tableId):
app.logger.info(f"query_covid_dataset with country '{country}' and tableId '{tableId}'")
client = bigquery.Client()
query = f"""
SELECT
date, num_reports
FROM `covid19_jhu_csse.{tableId}`
ORDER BY date ASC"""
app.logger.info(f'Running query: {query}')
query_job = client.query(query)
results = query_job.result()
# for row in results:
# print("{}: {} ".format(row.date, row.num_reports))
df = (
results
.to_dataframe()
)
app.logger.info(df.tail())
ax = df.plot(kind='line', x='date', y='num_reports')
ax.set_title(f'Covid Cases in {country}')
# ax.set_xlabel('Date')
# ax.set_ylabel('Number of cases')
#plt.show()
file_name = f'chart-{tableId}.png'
app.logger.info(f'Saving file locally: {file_name}')
plt.savefig(file_name)
upload_blob(file_name)