Google Colab

Google Colab #

Instal python packages #

Use !pip install ...

Environment variables #

Add secrets on the notebook itself

  • Navigate to the “Secrets” pane from the left navigation bar
  • Add the secret name and value
  • Turn on the toggle of “Notebook access”
  • Access your secret keys in notebook via:
from google.colab import userdata
userdata.get('MY_KEY')
  • Set it to the OS environment variables via:
os.environ['MY_KEY'] = userdata.get('MY_KEY')

Pretty print data #

import pandas as pd
pd.DataFrame(dataVar)

Use javascript in notebook #

!npm i jupnode
import jupnode
sh`npm init -y`
sh`npm install aws-sdk`
console.log('x')

Run async code in notebook #

Error: “asyncio.run() cannot be called from a running event loop”

import nest_asyncio

nest_asyncio.apply()