Tools & Setup

Data Science · Lesson 2 of 32 7 min read Updated

You can learn this whole course in your browser, because every python tryit example runs there. For your own projects, though, you will want a proper setup on your computer or in the cloud.

In this lesson you will meet the main tools data scientists use, learn how notebooks work, and install the libraries with uv or pip.

Where to write data science code

ToolRuns onGood forWatch out for
This site's Try-it editorYour browserLearning and quick experimentsNo internet access from Python, no saving
Google ColabGoogle's cloud serversStarting fast on any computer, free GPU time for MLNeeds a Google account; uploaded files are lost when the session ends
JupyterLab / Jupyter NotebookYour computerExploring data step by step with charts inlineCells run out of order can confuse you
VS CodeYour computerNotebooks and normal .py files in one editor, Git, debuggingNeeds the Python and Jupyter extensions
Plain .py scriptsAnywhereRepeatable reports, scheduled jobs, productionNo inline charts while exploring

Most people use more than one: a notebook while exploring, then a .py script once the analysis is final and needs to run every week.

How notebooks work

A notebook (a file ending in .ipynb) is a document made of cells. A code cell holds Python; a Markdown cell holds headings and notes. When you run a cell, its output, including tables and charts, appears right under it. Behind the notebook a Python process called the kernel keeps all your variables in memory between cells.

Two notebook habits differ from normal Python:

  • The last line of a cell is displayed automatically. If a cell ends with sales.head(), the notebook shows a formatted table without print(). In a .py script, and in this site's editor, you must call print() yourself.
  • Run order matters, not cell position. If you run cell 5, then change cell 2 and do not rerun it, your variables no longer match the code you see. Before you share a notebook, use "Restart kernel and run all cells" to prove it works from top to bottom.

Installing with uv

uv is a fast tool that creates a project folder, a private environment and a lock file of exact package versions in a few commands. After installing uv from its official site, run these commands in a terminal:

Terminal
uv init sales-analysis
cd sales-analysis
uv add numpy pandas matplotlib scipy
uv add --dev jupyterlab
uv run jupyter lab

uv init creates the project with a pyproject.toml file. uv add installs packages into the project's own environment and records them, so a classmate can recreate exactly the same setup with uv sync. jupyterlab is added as a development tool because you need it to explore, not to run the final script. uv run jupyter lab starts JupyterLab inside that environment and opens it in your browser.

Installing with pip

pip is the standard installer that comes with Python. Use it inside a virtual environment, a private folder of packages for one project, so projects do not break each other.

Terminal
python -m venv .venv
.venv\Scripts\activate
pip install numpy pandas matplotlib scipy jupyterlab
jupyter lab

The second line is for Windows. On macOS and Linux, activate with source .venv/bin/activate instead. To use the same environment in VS Code, open the folder, install the Python and Jupyter extensions, create a file ending in .ipynb, and pick .venv as the kernel in the top-right corner.

Check your versions

Whichever tool you use, check which versions you have. Behaviour changed in NumPy 2 and pandas 3, so an old tutorial may show different output from your computer. Run this in the browser editor:

PythonRun it yourself
import platform
import numpy as np
import pandas as pd
import matplotlib
import scipy

print("Python    ", platform.python_version())
print("NumPy     ", np.__version__)
print("pandas    ", pd.__version__)
print("matplotlib", matplotlib.__version__)
print("SciPy     ", scipy.__version__)
Output
Python     3.14.2
NumPy      2.4.6
pandas     3.0.2
matplotlib 3.10.8
SciPy      1.18.0

The browser editor runs Python 3.14 compiled to WebAssembly, with the same library versions this course teaches.

Standard import names

Every data scientist uses the same short names when importing. Stick to them, because every tutorial, answer and colleague will expect them.

PythonRun it yourself
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

marks = np.array([72, 85, 64, 91])
table = pd.DataFrame({"student": ["Aarav", "Priya", "Kabir", "Meera"], "marks": marks})
print(table)
print("Class average:", marks.mean())

plt.bar(table["student"], table["marks"])
plt.title("Marks in the unit test")
plt.show()
Output
  student  marks
0   Aarav     72
1   Priya     85
2   Kabir     64
3   Meera     91
Class average: 78.0

np, pd and plt are conventions, not rules, but writing import pandas as panda would only confuse readers. The bar chart appears as an image: Meera's bar is the tallest and Kabir's the shortest.

Common mistakes

  • Installing packages globally. Running pip install without a virtual environment mixes packages from every project and leads to version clashes. Use uv or a .venv.
  • Installing into the wrong Python. In a notebook, %pip install installs into the kernel the notebook is using; !pip install may install somewhere else.
  • Expecting notebook display in a script. A bare df.head() on the last line shows nothing in a .py file. Use print(df.head()).
  • Sharing a notebook that only works out of order. Restart and run all cells before you send it.

Key points

  • Use the browser editor to learn, Google Colab for zero setup, and JupyterLab or VS Code for your own projects.
  • A notebook is made of cells; the kernel keeps variables between them, and the last expression in a cell is displayed.
  • uv init, uv add and uv run create a reproducible project; pip with a virtual environment also works.
  • Check versions with np.__version__ and pd.__version__, because NumPy 2 and pandas 3 changed some behaviour.
  • Import with the standard names np, pd and plt.

Exercise

Write a small program for the browser editor that imports NumPy and pandas with their standard names, creates a NumPy array of the daily footfall at a Lucknow bookshop for one week (any seven numbers), prints the total and the average, and prints the pandas version.

Show solution
Python
import numpy as np
import pandas as pd

footfall = np.array([120, 95, 102, 130, 160, 210, 190])
print("Total visitors:", footfall.sum())
print("Average per day:", footfall.mean())
print("pandas", pd.__version__)
Output
Total visitors: 1007
Average per day: 143.85714285714286
pandas 3.0.2

sum() and mean() work on the whole array at once. In a notebook you could leave out print() on the last line, but in a script or this editor you need it.

Quick Quiz

1. In a Jupyter notebook, what keeps your variables in memory between cells?

2. Which command adds pandas to a uv project?

3. A script ends with the line sales.head() and prints nothing. Why?

4. Why should you use a virtual environment for each project?

Learn Data Science with a mentor

Free lessons get you started. Our Data Science & Machine Learning training adds real projects and code reviews from working developers.

  • Project-based learning
  • Mentor code reviews
  • Free counselling call