-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.py
35 lines (25 loc) · 1.21 KB
/
data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import streamlit as st
from google.oauth2 import service_account
from google.cloud import bigquery
from queries import au_stats, queensland_stats_city, queensland_stats_asn, queensland_median_city, queensland_median_asn, au_median
# Create API client.
project_id = 'measurement-lab'
location = 'US'
credentials = service_account.Credentials.from_service_account_info(
st.secrets["gcp_service_account"]
)
client = bigquery.Client(project=project_id, location=location,credentials=credentials)
# Get Data
# df = client.query(au_stats.query).to_dataframe()
# df.to_csv('data/au_stats.csv', index=False)
df = client.query(au_median.query).to_dataframe()
df.to_csv('data/au_median.csv', index=False)
# df = client.query(queensland_stats_city.query).to_dataframe()
# df = df[df['total'] > 1000]
# df.to_csv('data/queensland_stats_city.csv', index=False)
# df = client.query(queensland_median_city.query).to_dataframe()
# df.to_csv('data/queensland_median_city.csv', index=False)
# df = client.query(queensland_stats_asn.query).to_dataframe()
# df.to_csv('data/queensland_stats_asn.csv', index=False)
# df = client.query(queensland_median_asn.query).to_dataframe()
# df.to_csv('data/queensland_median_asn.csv', index=False)