Introduction to Google Colab
Before starting Data Science, you should know about Google Colab (short for Colaboratory).
Typically, we use VS Code to write Python code. However, when working with data and machine learning, you need to inspect datasets, plot graphs, and check outputs immediately after running a few lines. Developers usually use a tool called Jupyter Notebooks for this.
Google Colab is a free, cloud-based version of Jupyter Notebooks provided by Google.
Why Use Google Colab?
- Zero Setup: You don't need to install Python, Pandas, or any other library on your local computer. Everything is pre-installed.
- Free Hardware Access: Running machine learning models requires fast computers. Google Colab gives you free access to GPUs in the cloud.
- Instant Feedback: You can run code in small blocks and see the charts and output directly below it.
- Easy Sharing: You can save notebooks to Google Drive and share them with a link, just like Google Docs.
How to Open Colab?
- Go to colab.research.google.com in your browser.
- Sign in using your Google account.
- Click "New Notebook" at the bottom of the pop-up window.
That's it! Your workspace is ready.
What are Cells?
In VS Code, you write code in one long file. In Google Colab, you write code in smaller blocks called Cells.
- Code Cell: Where you write Python code. Press
Shift + Enteror click the "Play" icon to execute only that cell. - Text Cell: Where you write notes, headings, or add images using Markdown.
:::info Try It Now
Open a new Colab Notebook, type print("Hello Data Science") in the first Code Cell, and press Shift + Enter. The output will appear right below the cell!
:::
For the upcoming chapters on Pandas and Matplotlib, we recommend using Google Colab so you can see your data and charts immediately.