Google Colab Tips and Tricks

- Scratchpad Notebook: https://colab.research.google.com/notebooks/empty.ipynb
- Open Notebooks from GitHub: simply replace github.com with githubtocolab.com. It will redirect you to a Colab notebook.
- Timing Execution of Cell: hover over the cell run icon and you will get an estimate of the execution time taken
- Run part of a cell: Click
Runtime -> Run Selectionbutton or using the keyboard shortcutCtrl + Shift + Enter - Most commonly used shortcuts:
- Run cell (
Ctrl + Enter) - Run cell and add new cell below (
Alt + Enter) - Run cell and goto the next cell below (
Shift + Enter) - Comment current line (
Ctrl + /)
- Run cell (
- Jupyter Notebook Keyboard Shortcuts: Click Tools -> Keyboard shortcuts or Just add
Ctrl + Mbefore whatever keyboard shortcut you were using in Jupyter. For example- add a cell above (
Ctrl + M + A) - Add a cell below (
Ctrl + M + B) - Change cell to code (
Ctrl + M + Y) - Change cell to markdown (
Ctrl + M + M)
- add a cell above (
- Jump to Class definition: press
Ctrland then clicking a class name - Run bash commands:
- Download dataset from the web with
!wget <ENTER URL> - Install libraries with
!pip install <LIBRARY> - Clone a git repository with
!git clone <REPOSITORY URL> - Change directory with
!cd
- Download dataset from the web with
- Mount your Google Drive to Colab:
from google.colab import drive drive.mount('/content/gdrive') - To upload a file (or several) from your computer, run:
from google.colab import files files.upload() - To download a file, run:
from google.colab import files files.download('path/to/your/file') - Run R programs in Google Colab: You can use R programming language in Google Colab by going to https://colab.to/r. It will open a new notebook with R set as the kernel instead of Python.
- “Open in Colab” Badge: You can add a ‘Open in Colab’ badge to your README.md or jupyter notebooks using the following markdown code:
[](https://colab.research.google.com/notebooks/basic_features_overview.ipynb) - Run Rust programs in Google Colab: Go to https://colab.to/rust. Then rust the first cell. Reload the page. Skip the first and run other cells, or write your own codes.
References:




