Run a legacy SQL query with pandas-gbq

Use the pandas-gbq package to run a query using legacy SQL syntax.

Code sample


Before trying this sample, follow the Python setup instructions in the BigQuery quickstart using client libraries. For more information, see the BigQuery Python API reference documentation.

sql = """
SELECT country_name, alpha_2_code
FROM [bigquery-public-data:utility_us.country_code_iso]
WHERE alpha_2_code LIKE 'Z%'
df = pandas_gbq.read_gbq(
    # Set the dialect to "legacy" to use legacy SQL syntax. As of
    # pandas-gbq version 0.10.0, the default dialect is "standard".

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.