Visualize query results
You can use visualization cells in Colab Enterprise notebooks to generate and customize charts and graphs for large-scale analysis without leaving your notebook environment.
This guide shows you how to use visualization cells in Colab Enterprise
notebooks to analyze data from the bigquery-public-data.ml_datasets.penguins
public dataset. You will complete the following tasks:
- Execute SQL queries directly in a notebook.
- Filter query results using Python DataFrames.
- Generate and customize vertical bar charts without writing code.
Before you begin
-
In the Cloud de Confiance console, on the project selector page, select or create a Cloud de Confiance project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Cloud de Confiance project.
Verify that the BigQuery API is enabled.
If you created a new project, the BigQuery API is automatically enabled.
Required permissions
To create and run notebooks, you need the following Identity and Access Management (IAM) roles:
Create a Colab Enterprise notebook
To create a new notebook, follow the instructions in Create a notebook from the BigQuery editor.
Run a SQL query in a Colab Enterprise notebook
To run a SQL query in a notebook, follow these steps:
In your notebook, click the Code drop-down and select Add SQL cell.
Enter the following query:
SELECT * FROM `bigquery-public-data.ml_datasets.penguins`;Click Run cell.
The results of the query are automatically saved in a DataFrame called
df.Create another SQL cell and change the title to
female_penguins.Enter the following query, which references the DataFrame you just created and filters the results to only include female penguins:
SELECT * FROM {df} WHERE sex = 'FEMALE';Click Run cell.
The results of the query are automatically saved in a DataFrame called
female_penguins.
Visualize results in a Colab Enterprise notebook
In your notebook, click the Code drop-down and select Add visualization cell.
Click Choose a dataframe and then select
female_penguins.A chart interface appears.
Click Scatter chart to open a chart menu, then select the Vertical bar chart.
In the Metric section, check that
culmen_length_mmandculmen_depth_mmappear. If a metric is missing, click Add metric and select it. To remove a metric, hold the pointer over the metric name and then click Close.Hold the pointer over the aggregation type (for example, AVG or SUM) to reveal the icon, then click it to change the aggregation type to Average.

Clean up
The easiest way to eliminate billing is to delete the project that you created for the tutorial.
To delete the project:
- In the Cloud de Confiance console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
What's next
- Learn more about BigQuery DataFrames.
- Learn more about SQL cells in Colab Enterprise.
- Learn more about visualization cells in Colab Enterprise.
- Learn how to visualize graphs using BigQuery DataFrames.
- Learn how to use a BigQuery DataFrames notebook.