Last active
May 16, 2020 23:06
-
-
Save JoeThunyathep/d27b3e124ca93eee84adc65d8ca27633 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pandas as pd | |
from google.cloud import bigquery | |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="Path to your Service Account ~ JSON key" | |
client = bigquery.Client() # Start the BigQuery Client | |
# Input your Query Syntax here; You may try it first at https://console.cloud.google.com/bigquery | |
QUERY = ( | |
'SELECT * FROM `bigquery-public-data.covid19_nyt.us_counties` ' | |
'ORDER BY date DESC,confirmed_cases DESC ' | |
'LIMIT 20') | |
query_job = client.query(QUERY) # Start Query API Request | |
query_result = query_job.result() # Get Query Result | |
df = query_result.to_dataframe() # Save the Query Resultto Dataframe | |
# --------------------------------------------- | |
# ---- Continue Data Analysis with your DF ---- | |
# --------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment