Created
June 2, 2019 05:09
-
-
Save guerbai/c13f0862f32c88be62ec8d8d8f3f2d0f to your computer and use it in GitHub Desktop.
bigquery初始化 #Jupyter
This file contains 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
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