從已完成的查詢作業建立 BigQuery DataFrame

使用 BigQuery DataFrames API 探索查詢工作結果,這些工作可能是在其他位置啟動,例如 BigQuery 控制台或 bq CLI。

程式碼範例

Python

在試行這個範例之前,請先按照 BigQuery 快速入門導覽課程:使用用戶端程式庫中的 Python 設定說明進行操作。詳情請參閱 BigQuery Python API 參考說明文件

如要向 BigQuery 進行驗證,請設定應用程式預設憑證。 詳情請參閱「設定用戶端程式庫的驗證機制」。

from google.cloud import bigquery

import bigframes.pandas as bpd

# Project ID inserted based on the query results selected to explore
project = your_project_id
# Location inserted based on the query results selected to explore
location = "us"
client = bigquery.Client(project=project, location=location)

# Job ID inserted based on the query results selcted to explore
job_id = JOB_ID
job = client.get_job(job_id)
destination = str(job.destination)

# Load data from a BigQuery table using BigFrames DataFrames:
bq_df = bpd.read_gbq_table(destination)

後續步驟

如要搜尋及篩選其他 Google Cloud 產品的程式碼範例,請參閱Google Cloud 範例瀏覽器