Google Colab - a must-have tool for Developer and Data Scientist

Google Colab - a must-have tool for Developer and Data Scientist

13 amazing features and usage tips.


What is Google Colab?

Colaboratory, or “Colab” for short, is a product from Google Research. Colab allows anybody to write and execute arbitrary python code through the browser, and is especially well suited to machine learning, data analysis and education.

Google Colab is based on Jupyter Notebook, a web application for creating “computational documents” (according to Jupyter Notebook creators). In simple words, Jupyter Notebook allows you to write a kind of streamlined document (or notebook) that includes code snippets, outputs, texts, images and many more, but in addition to being able to read and write this beautifully formatted document, you can also execute its code parts and examine the inputs in the same document.

If you are unfamiliar with Jupyter Notebooks, please take a look at a Jupyter Notebook example (a picture is worth a thousand words…)

For those who are familiar with Jupyter Notebook, I would define Google Colab as: “hosted Jupyter Notebook on steroids” 💪

Google Colab is a 🆓 web application that is available to you with you regular Google account (just like Google Drive or Gmail)


Use cases — when you should consider using Google Colab
  • Educational: if you are new to Python, and you are looking for a quick start to follow some tutorial, or to write and try simple python code, Colab is a great option! All you need to do is to open your browser and start coding — no installations needed!
  • Sandbox: even if you are an experienced developer, and you are working on a complex project, you may find Google Colab extremely useful if you just want to try unknown (and potentially heavy) packages without the need to install them on your local environment!
  • Presentations / talks: if you need to give a talk on a topic that requires you to present and / or run Python code, Google Colab is your best friend! First of all, it allows you to write and run your code during your talk seamlessly, and in a very presentational way (check out my tips below). In addition, if you happen to give some kind of hands-on session/course for corporate companies, you probably know what a headache 🤕 it is to convince them to install something on their company’s laptops. Now imagine what it takes to convince corporate IT to install all the stuff needed for one-day seminar in deep learning, for example. Installation requirements will probably include: python, pip, dozen of python packages, jupyter, etc… There is a great chance they will give up on your session rather than investing dozens of IT hours to install everything on personal laptops of 30 employees. Since Colab allows running all the needed stuff for deep learning on the cloud using your browser and the only thing you need is Google account, I was able to conduct my courses easily in many big corporate companies (and their IT was happy and endlessly grateful)
  • Data Science: if you are a data scientist, or if you are working on a personal project that involves data analysis and/or machine learning, not only will Google Colab provide you a convenient and interactive environment with all the most popular packages pre-installed, but it will also provide you with free GPU to train your models!

Main advantages
  • No downloads or installations needed! Really, not at all! Google Colab is based on Python 3 and comes with main data science, machine learning, deep learning, image processing and NLP packages pre-installed: numpy, pandas, sklearn, scipy, matplotlib, seaborn, tensorflow, pytorch, nltk, spacy, and many more are instantly available to you.
  • You get compute resources available to you free of charge! The resources you get are as follows: — 12 GB RAM — 100GB of disk space — GPU/TPU ❗️ Let’s admit, not many of us have GPU installed on their personal laptops, so if you are working with heavy models, an ability to use GPU is an incredibly important advantage!
  • Collaboration Google Colab allows you to write code in an interactive and convenient way, share it with others and collaborate on it, just like if it was a regular document.

13 amazing features and usage tips
  1. Files upload / download: Just click the folder 📁 icon on the left menu pane and you’ll get an access to current runtime session files, from here you can upload and download files as well:

Blank Google Colab notebook with a code cell, ready for writing and running Python code. Ideal for data science, machine learning, and AI development.

After simple drag-and-drop you can access your uploaded files from the Python code as follows:

Google Colab notebook with Python code to import the Pandas library and read the 'biztalkfile.csv' file. A common task in data analysis and data science projects.

Note that all the uploaded files are only available as long as current session is active. After the session disconnects, all the files will be lost. Hence I suggest mounting your Google Drive to Colab. It will guarantee that all the files you are creating from your python code are safely stored in your drive.


  1. Mounting your Google Drive: Open the left-pane menu and click the Drive icon:

Google Colab notebook showing the 'Files' section, where users can manage and access data files for their projects.

Follow the instructions and authenticate your drive, and in 2 seconds all the files from your Google drive will be instantly and seamlessly available to your python code without the need to upload or download them:

Google Colab notebook with Python code to import the Pandas library and read the 'store_data.csv' file from Google Drive. A common task in data analysis and data science projects.


  1. Interactive tables for data analysis: Interactive tables allow you to view / filter / sort your tabular data not only from code, but also using interactive user-friendly UI:

Google Colab notebook with Python code to load the 'california_housing_test.csv' dataset using Pandas and display the first few rows. A common task in data exploration and analysis.

Just click on the icon under the table, and you’ll get a full search, filter and sort functionality:

Google Colab notebook displaying the California housing dataset using Pandas, showcasing columns like longitude, latitude, housing median age, and median house value for data analysis and machine learning.


  1. Variable Inspector: Give a try to Colab Variable Inspector (click the x icon in the left-pane menu). It displays all the variables currently defined in your notebook and allows you to examine them more closely. The variables are automatically updated, added and removed as you execute your code.

Google Colab code editor demonstrating Pandas data analysis in Python. Level up your AI and data science skills with EduLabs training.


  1. Notebook collaboration with comments: Comments are available for each code cell in Colab notebook, and the functionality is similar to this of a regular Google Doc. Great collaboration feature!

Enhance your data analysis workflow with Google Colab's collaborative features, enabling instant feedback on Python and Pandas code. Discover more with EduLabs.


  1. Playground Mode: 🤾‍♀ In Playground Mode changes you make to the notebook will not be saved. Very useful for presentations and playing with the code! Access Playground mode from the upper menu: File =>Open in playground mode

Start a new or open an existing Python notebook effortlessly with Google Colab's intuitive interface. EduLabs provides comprehensive Colab training.

Now you can safely play with your code without changing the original notebook.

Google Colab notebook in Playground Mode, indicating that code changes won't be saved. Ideal for experimentation and learning Python.


  1. Table of contents: Use automatically created table of contents for your notebook, and you’ll never get lost as the notebook get longer and longer. Click on the upper icon in the left pane menu, and you’ll get a navigable table of contents for your notebook based on section and titles you wrote.

Stay organized with Google Colab's Table of Contents feature, making it easy to navigate long Python notebooks. Learn more about efficient coding with EduLabs.


  1. Forms: Forms allow you to get inputs from users in an interactive and user-friendly way, store their input values in variables and continue working with these variables in your code. The input forms in your notebook will look like this:

Google Colab form with string fields: a text input box and a dropdown menu for user interaction within the code environment. Easily input and process dates in Google Colab with dedicated date fields, ideal for data analysis and manipulation tasks. Explore the power of Google Colab for visualizing and adjusting numerical data with intuitive sliders and input fields for seamless manipulation.

The following code will create the first form presented above:

Snippet of Python code in a Google Colab notebook showcasing how to define and utilize interactive string fields.

Check out the official Forms Colab for more options and code snippets.


  1. GitHub integration: You can easily save all your notebooks to your GitHub account. In the upper menu navigate to File => Save a copy in GitHub, and after short authentication process you will be able to sync your Colab notebooks with your GitHub:

Learn Google Colab for AI and data science! Our courses cover essential features like saving notebooks to Drive & GitHub for seamless project management. Master Google Colab & GitHub for AI! Our data science courses teach you how to write, share, and collaborate on code like this using Python and Pandas.


  1. Useful Magics: Magic commands in Jupyter notebook are special commands that provide special functionalities to your notebook. Magic commands are written in a regular code cell, and the command name is preceded by % or %% Below are a couple of very useful magic commands I use on a daily basis:
  • %%time: displays amount of time it takes to the cell code to run

Google Colab code snippet demonstrating a simple loop to calculate the sum of numbers from 1 to 10 million, showcasing its efficiency and ease of use for data science and development tasks.

  • %%html: formats html code written in the cell

Google Colab code snippet demonstrating HTML code for creating a spinning wheel animation with a blue marquee and overlapping rectangular shapes in red and blue.

  • %who: displays currently defined variables

Google Colab code snippet demonstrating how to create and manipulate variables of different data types, including integers and strings.

You can find more magic commands in Jupyter documentation. Take a look, there are many interesting magics!


  1. Running regular terminal commands: If you need to run an old good terminal command like ls, or cp, or pip install, or whatnot, you can do it just from a regular cell code, appending exclamation mark ! before the command.

Google Colab terminal output showing the installation of the spaCy natural language processing library, along with its dependencies, indicating that they are already satisfied in the current environment. Google Colab terminal output displaying system resource usage, including CPU, memory, and process information, relevant for AI training and development tasks.


  1. Use GPU / TPU for 🆓: Enable GPU/TPU for your current session from the top menu: File => Edit => Notebook Settings

Google Colab notebook settings dialog, allowing users to select hardware accelerator (GPU or TPU) for efficient AI model training, enable background execution, and choose whether to omit code cell output when saving.

You should avoid using GPU unless you really need one since GPU resources available to you are limited, though usually you get enough GPU for personal use. Read more about GPU resource limits here.


  1. Commands Palette: There are many more great features and options in Google Colab. Check them out in Commands Palette. In the top menu, go to: Tools =>Commands Palette, and continue exploring!

Google Colab notebook interface showing various options for creating and editing code cells, adding comments and sections, and managing runtime settings, essential tools for AI project proof-of-concept development.


I hope you found something new and useful in this article.

Thanks for reading!

Share :

Related Post

Python Regular Expressions - Cheat Sheet

Python Regular Expressions - Cheat Sheet

  • Valeria Aynbinder
  • Coding
  • 16 Oct, 2024

Many code examples + useful tips. Bonus added to the end of the post.Regular expressions is an extremely useful tool, and like any developer, I use it a lot when working with texts. Since I al

Read More
Stay Ahead with Google Sheets' New Feature: Conditional Notifications

Stay Ahead with Google Sheets' New Feature: Conditional Notifications

Google Sheets has always been a go-to tool for managing data, collaborating with teams, and automating tasks—but now it's even better! The new Conditional Notifications feature helps you stay on t

Read More