Skip to content

Instantly share code, notes, and snippets.

@JoeThunyathep
Last active May 16, 2020 23:06
Show Gist options
  • Save JoeThunyathep/d27b3e124ca93eee84adc65d8ca27633 to your computer and use it in GitHub Desktop.
Save JoeThunyathep/d27b3e124ca93eee84adc65d8ca27633 to your computer and use it in GitHub Desktop.
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