How to set up Google Colab for your first data science project
This guide shows you exactly how to set up a working data science environment using Google Colab.
What is Google Colab?
Google Colab is a cloud-based Python notebook environment.It allows you to:
- Write and run Python code
- Use pre-installed data science libraries
- Access free CPU/GPU resources
- Save work automatically to Google Drive
You don't need to install anything on your computer.
Step 1 — Open Google Colab
1. Go to: https://colab.research.google.com
2. Click "New Notebook"
You now have a working Python environment to start write scripts on.
Step 2 — Understand the Interface
A Colab notebook has cells.
There are two types of cells:
- Code cells → run Python
- Text cells → write notes (Markdown)
Run a cell with Shift + Enter
Step 3 — Verify Your Environment
Run this in a code cell:[ Press the Play Button]
Check installed libraries on Collab:
Step 4 — Install Missing Libraries (if needed)
Colab already includes most libraries, but, if something is missing:
Rule:
-
Use
!pip installinside a cell (note the starting exclamaition!) - Restart runtime if required
Step 5 — Import Core Libraries
Start every project with:
Step 6 — Load Data
Option A: Upload from your computer
Option B: Load from URL
df = pd.read_csv("https://example.com/data.csv")
df = pd.read_csv("https://example.com/data.csv")
Option C: Load from Google Drive
- Mount Drive:
from google.colab import drive
drive.mount('/content/drive')
- Access file:
df = pd.read_csv('/content/drive/MyDrive/your_file.csv')Now you are ready to start cleaning and visualizing your data.
Comments
Post a Comment