Google Cloud BigQuery

3.40.1 · active · verified Wed Mar 25

Official Python client for Google BigQuery. Current version: 3.40.1 (Mar 2026). v3.0 made google-cloud-bigquery-storage and pyarrow required dependencies. Authentication uses Application Default Credentials (ADC) — no explicit API key. query() returns a QueryJob — must call .result() to wait for completion. to_dataframe() dtype behavior changed in v3 (nullable pandas dtypes). Python 3.9+ required as of v3.x.

Warnings

Install

Imports

Quickstart

BigQuery Python client — query and to_dataframe with ADC auth.

# pip install 'google-cloud-bigquery[pandas]'
# Set up ADC: gcloud auth application-default login
# or set GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json

from google.cloud import bigquery

client = bigquery.Client(project='my-gcp-project')

# Query public dataset
query = """
    SELECT
        name,
        SUM(number) as total
    FROM `bigquery-public-data.usa_names.usa_1910_2013`
    WHERE state = 'CA'
    GROUP BY name
    ORDER BY total DESC
    LIMIT 5
"""

# Run query and wait for results
query_job = client.query(query)
rows = query_job.result()  # blocks until done

for row in rows:
    print(f'{row.name}: {row.total}')

# As DataFrame
df = rows.to_dataframe()
print(df.head())

view raw JSON →