Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

bigquery data using python

from google.cloud import bigquery

# Construct a BigQuery client object.
client = bigquery.Client()

query = """
    SELECT name, SUM(number) as total_people
    FROM `bigquery-public-data.usa_names.usa_1910_2013`
    WHERE state = 'TX'
    GROUP BY name, state
    ORDER BY total_people DESC
    LIMIT 20"""

query_job = client.query(query)  # Make an API request.

df = query_job.to_dataframe(max_results = 1000) # max_results - num of rows to get
print(df.head())
Source by pypi.org #
 
PREVIOUS NEXT
Tagged: #bigquery #data #python
ADD COMMENT
Topic
Name
7+7 =