Skip to content

Instantly share code, notes, and snippets.

@guerbai
Created June 2, 2019 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guerbai/c13f0862f32c88be62ec8d8d8f3f2d0f to your computer and use it in GitHub Desktop.
Save guerbai/c13f0862f32c88be62ec8d8d8f3f2d0f to your computer and use it in GitHub Desktop.
bigquery初始化 #Jupyter
from google.cloud import bigquery
# Create a "Client" object
client = bigquery.Client()
# Construct a reference to the "hacker_news" dataset
dataset_ref = client.dataset("hacker_news", project="bigquery-public-data")
# API request - fetch the dataset
dataset = client.get_dataset(dataset_ref)
# Construct a reference to the "comments" table
table_ref = dataset_ref.table("comments")
# API request - fetch the table
table = client.get_table(table_ref)
# Preview the first five lines of the "comments" table
client.list_rows(table, max_results=5).to_dataframe()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment