Code
Insert code cell below
Ctrl+M B
Text
Add text cell
Copy to Drive
Toggle header visibility
CodeText

Before you begin

  1. Use the Cloud Resource Manager to Create a Cloud Platform project if you do not already have one.
  2. Enable billing for the project.
  3. Enable BigQuery APIs for the project.
CodeText

Provide your credentials to the runtime

CodeText

CodeText

Optional: Enable data table display

Colab includes the google.colab.data_table package that can be used to display large pandas dataframes as an interactive data table. It can be enabled with:



If you would prefer to return to the classic Pandas dataframe display, you can disable this by running:

%unload_ext google.colab.data_table
CodeText

Use BigQuery via magics

The google.cloud.bigquery library also includes a magic command which runs a query and either displays the result or saves it to a variable as a DataFrame.


CodeText

CodeText


Use BigQuery through google-cloud-bigquery

See BigQuery documentation and library reference documentation.

The GSOD sample table contains weather information collected by NOAA, such as precipitation amounts and wind speeds from late 1929 to early 2010.


Declare the Cloud project ID which will be used throughout this notebook


CodeText

Sample approximately 2000 random rows


Full dataset has 114420316 rows

Describe the sampled data



View the first 10 rows

CodeText


CodeText

Use BigQuery through pandas-gbq

The pandas-gbq library is a community led project by the pandas community. It covers basic functionality, such as writing a DataFrame to BigQuery and running a query, but as a third-party library it may not handle all BigQuery features or use cases.

Pandas GBQ Documentation