[BigQuery Data Agents](/about/bigquery-data-agents) November 3, 2026

# BigQuery Data Science Agent: analysis in a notebook

Use the Data Science Agent in BigQuery Studio notebooks to explore GA4 data, forecast revenue, and segment sessions, with a plan you approve step by step.

![](/images/65d75b0ae8d69ef95785a5d6_david-pombar.webp)

**[David Pombar](/authors-guides/david-pombar)** Swiss army knife at Trackingplan

6 min read · 1387 words

A data agent answers “what was revenue by channel?” in a sentence. It is the wrong tool for “which kinds of sessions convert, and what does next month look like?” That is an analysis: several steps, a model, charts, and choices someone should be able to inspect later. In BigQuery, the agent for that is the Data Science Agent, and it works in a notebook.

This guide runs three analyses on your agent layer with it: an exploration, a forecast, and a segmentation. The point is not the results, since the public sample is obfuscated. It is learning how to direct the agent and check its work.

![A round-bottom flask with an amber liquid held by a clamp in a chemistry laboratory, with tubing above it](/images/bigquery-data-science-agent-lab.jpg)

An experiment you can repeat beats a result you can’t explain. Image: National Center for Advancing Translational Sciences, Wikimedia Commons, public domain

**Goal of this guide:** three analyses in a notebook, written by the agent, reviewed and rerun by you. ** You need:** the `agent_layer` tables from [guide 4](/guides/ga4-views-for-bigquery-agents), or the pipeline from [guide 9](/guides/bigquery-data-engineering-agent).

## Open the agent

The [Data Science Agent](https://docs.cloud.google.com/bigquery/docs/colab-data-science-agent) runs in Colab Enterprise notebooks. Your project needs four APIs enabled: BigQuery, Gemini for Google Cloud, Dataform, and Compute Engine.

In BigQuery, open your project, go to **Notebooks > New notebook > Empty notebook**, and click the spark button, ** Toggle Gemini in Colab**. A side panel opens where you write prompts.

To give it data, select a BigQuery table with the table selector, type its name as `project_id:dataset.table`, or mention it with `@`, which searches the tables in the current project. You can also upload a CSV file.

## How it works: plan, accept, run

![Diagram of the Data Science Agent loop: a prompt produces a plan of steps, you refine it and click Accept and run, the agent writes and runs code cells in the notebook, and asks again before later steps.](/images/bigquery-data-science-agent-plan.webp)

Nothing runs until you accept the plan, and later steps ask again.

You describe the analysis; the agent writes a plan of steps. You can refine the plan before anything runs. When you click **Accept & run**, it writes code and text cells into the notebook and runs them on the notebook’s runtime. Later steps can ask for another ** Accept & run**, and ** Cancel** stops it at any point.

The result is an ordinary notebook. The code stays when the agent is done: you can read it, change it, rerun it, and share it. That is the main difference from a data agent’s answer, and the main reason to use this agent for anything you will present.

## Choose the engine with the prompt

By default the agent writes Python with open-source libraries such as scikit-learn, pulling data into the notebook. A keyword in the prompt changes that:

| Say in the prompt | It uses |
| --- | --- |
| nothing | Python with open-source libraries |
| “SQL” or “BigQuery ML” | BigQuery ML, inside BigQuery |
| “BigQuery DataFrames” or “BigFrames” | BigQuery DataFrames |
| “Apache Spark” or “PySpark” | PySpark |

For GA4 data at any real scale, prefer BigQuery ML or BigQuery DataFrames: the work runs in BigQuery instead of copying the table into the notebook.

## Analysis 1: explore the sessions

```text
Explore @agent_layer.sessions: row count, date range, share of missing values
per column, sessions and conversion rate by device_category and medium, and
a chart of daily sessions. Point out anything that looks unusual.
```

Read the plan before you accept it. Check that it computes conversion rate as converted sessions over all sessions, not something else. When it runs, look at the missing values first: on the public sample, some columns hold placeholder values, and on your own data a column that is 40% empty is a tracking question before it is an analysis question.

## Analysis 2: forecast daily revenue

```text
Using BigQuery ML, build a daily revenue series from @agent_layer.purchases
and forecast the next 30 days. Show the forecast with its prediction
interval on a chart, and evaluate the model on the last 14 days of history.
```

Saying “BigQuery ML” makes the agent build the series and the model in SQL. Check three things in the code: that every day appears in the series, including days with no purchases; that the evaluation holds out the last days rather than random ones; and that the chart shows the interval, not only the line. Three months of obfuscated sample data won’t produce a forecast worth trusting; the exercise is to read how it was built.

## Analysis 3: segment the sessions

```text
Cluster the sessions in @agent_layer.sessions into four to six segments using
device_category, medium, page_views and converted. Describe each segment in
plain language with its size and conversion rate, and explain how you chose
the number of segments.
```

Clustering always finds segments, whether or not they mean anything. Ask the agent to justify the number it chose, and read the description of each segment against the numbers in the notebook, not only its summary.

## Check its work

Everything from [guide 6](/guides/check-bigquery-agent-answers) applies, with more code to read. For any analysis you will share:

-   Rerun the notebook from the top in a fresh runtime. If it doesn’t run, it isn’t done.
-   Check the first query of every step against the checklist from [guide 2](/guides/sql-for-bigquery-data-agents).
-   Look for silent filters: rows dropped for missing values, outliers removed, dates cut off.
-   Ask the agent to explain any step you don’t understand, in a new prompt.

## Bring the results back to your data agent

An analysis is most useful when its results become something people can ask about. Three ways to close that loop:

-   **Segments as a column.** If the segmentation holds up, ask the Data Engineering Agent from guide 9 to add the segment to `agent_layer.sessions`, with a description that says how it was computed and when. Your data agent can then answer “conversion rate by segment”.
-   **Definitions in the glossary.** Each segment gets a glossary term in your data agent, with the plain-language description from the notebook, so “high-intent mobile sessions” means the same thing to everyone who asks.
-   **Forecasts as a table.** Write the forecast to a table, with the date it was produced, and add a verified query that reads it. People asking “what do we expect next month?” then get the number your analysis produced, not a new one improvised in a chat.

Each of these turns a one-off notebook into context the whole team uses, and each one needs a test case in your set from guide 8.

## When to use which agent

| You want | Use |
| --- | --- |
| A number, now, in a chat | A data agent (guides 5 to 8) |
| A pipeline that rebuilds tables every day | The Data Engineering Agent (guide 9) |
| An analysis with steps, charts, or a model, that someone can rerun | The Data Science Agent |

## Exercise

Run the three analyses. For each one, write down every choice the agent made that you didn’t specify: a filter, a parameter, a definition. Then rerun the notebook from the top and confirm it reproduces.

## How to know you got it right

-   You refined at least one plan before accepting it.
-   Your forecast was built with BigQuery ML and evaluated on held-out days.
-   Your notebook reruns from the top without errors.
-   You can say when you would use this agent instead of a data agent.

## Resources

-   [Use the Data Science Agent](https://docs.cloud.google.com/bigquery/docs/colab-data-science-agent), Google Cloud docs: setup, data sources, the plan workflow, and example prompts.
-   [Boost Productivity with Gemini in BigQuery](https://www.skills.google/course_templates/1169), Google Cloud Skills Boost: an introductory course on Gemini’s help across BigQuery, including notebooks and data canvas.
-   [Advanced SQL](https://www.kaggle.com/learn/advanced-sql), Kaggle Learn: analytic functions, the SQL behind most time series work.

## FAQ

**What is the BigQuery Data Science Agent?** An agent inside Colab Enterprise notebooks in BigQuery Studio. You describe an analysis, it writes a plan, and after you accept it, it writes and runs the code in the notebook: exploration, charts, forecasting, and machine learning, on BigQuery tables or CSV files.

**How is the Data Science Agent different from a data agent?** A data agent answers a question with a query and a number, in a chat. The Data Science Agent runs a multi-step analysis in a notebook, with Python or BigQuery ML, and leaves you the code. Use the data agent for questions, and the Data Science Agent for analysis you want to inspect, rerun, or hand over.

**Can the Data Science Agent use BigQuery ML?** Yes. By default it writes Python with open-source libraries; mention SQL or BigQuery ML in the prompt and it uses BigQuery ML instead. Mentioning BigQuery DataFrames or Spark selects those libraries.

**Next:** [Build your own: the Conversational Analytics API, ADK, and MCP](/guides/bigquery-agents-api-adk-mcp).

Part of[BigQuery data agents: a guide series from zero to expert](/guides/bigquery-data-agents)

On this page

1.  [*01*Open the agent](#open-the-agent)
2.  [*02*How it works: plan, accept, run](#how-it-works-plan-accept-run)
3.  [*03*Choose the engine with the prompt](#choose-the-engine-with-the-prompt)
4.  [*04*Analysis 1: explore the sessions](#analysis-1-explore-the-sessions)
5.  [*05*Analysis 2: forecast daily revenue](#analysis-2-forecast-daily-revenue)
6.  [*06*Analysis 3: segment the sessions](#analysis-3-segment-the-sessions)
7.  [*07*Check its work](#check-its-work)
8.  [*08*Bring the results back to your data agent](#bring-the-results-back-to-your-data-agent)
9.  [*09*When to use which agent](#when-to-use-which-agent)
10.  [*10*Exercise](#exercise)
11.  [*11*How to know you got it right](#how-to-know-you-got-it-right)
12.  [*12*Resources](#resources)
13.  [*13*FAQ](#faq)

**Stop babysitting tags**

Trackingplan audits your real user data around the clock and flags issues before they cost you.

[Start free trial →](https://app.trackingplan.com/signup)

![](/images/65d75b0ae8d69ef95785a5d6_david-pombar.webp)

**David Pombar** Swiss army knife at Trackingplan

Read more from David, a Senior Product Strategist with 18+ years in digital product development and an atypical error detection knack.

Share Copy link [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fwww.trackingplan.com%2Fguides%2Fbigquery-data-science-agent) [X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fwww.trackingplan.com%2Fguides%2Fbigquery-data-science-agent&text=BigQuery%20Data%20Science%20Agent%3A%20analysis%20in%20a%20notebook)

Read next

[All Guides →](/guides)

-   [
    
    7 minBigQuery Data AgentsNovember 3, 2026
    
    ### BigQuery agents in your code: the API, ADK, and MCP
    
    Create and query BigQuery data agents from Python with the Conversational Analytics API, give an ADK agent BigQuery tools, and connect assistants over MCP.
    
    by **David Pombar**](/guides/bigquery-agents-api-adk-mcp)
-   [
    
    7 minBigQuery Data AgentsNovember 3, 2026
    
    ### BigQuery Data Engineering Agent: pipelines in plain English
    
    Use the BigQuery Data Engineering Agent to turn your GA4 agent layer into a Dataform pipeline, set team rules in GEMINI.md, and fix failed runs.
    
    by **David Pombar**](/guides/bigquery-data-engineering-agent)
-   [
    
    5 minBigQuery Data AgentsNovember 3, 2026
    
    ### BigQuery data agents: a guide series from zero to expert
    
    A step-by-step series on BigQuery data agents: from your first query to agents you can trust in production, on GA4 data, with Google’s docs and courses.
    
    by **David Pombar**](/guides/bigquery-data-agents)

Trackingplan

## See everything. Miss nothing.

Your implementations audited around the clock with real-time, real-user data. Real-time alerts about errors or changes in your data, campaigns, pixels, privacy and consent. Let AI flag issues before they cost you.

[Start free trial →](https://app.trackingplan.com/signup) [Book a demo](/demo)
