📂Sample Python Code

Below are sample codes for accessing BigQuery from Google Colab. The code might be different depending on your specific environment.

Required Packages

Authentication is required before the data can be access from BigQuery.

# Authentification of google colab user 

from google.colab import auth
auth.authenticate_user()

After authentication, import the bigquery package from Google Cloud.

# Importing the bigquery package to link our colab notebook to bigquery

from google.cloud import bigquery

# Accessing user's project on bigquery, make sure the project name is correct

client = bigquery.Client(project="nansen-query")

Import other required packages. The below are required to run the rest of the examples. You may require different packages for your specific use case.

# Importing relevant python libraries

import pandas
from matplotlib import pyplot as plt
import matplotlib as mpl

More examples can be found here: https://www.kaggle.com/code/yazanator/analyzing-ethereum-classic-via-google-bigquery/notebook

Last updated