Course page
Log in

You are watching a free preview. Enroll to open all 25 lessons, track progress and ask the course tutor.

Enroll for $49.99

Section 1: Getting started with pandas

Setting up Jupyter and loading data

Article 12 min Lesson 2 of 25 Preview

We work in Jupyter notebooks, which combine code, results, charts and notes in one document. They are ideal for exploration, where you try something, look at the output and decide the next step.

Installation

Create a project and install the tools with uv (or pip in a virtual environment):

uv init bike-analysis
cd bike-analysis
uv add pandas pyarrow matplotlib jupyterlab openpyxl
uv run jupyter lab

JupyterLab opens in your browser. Create a new notebook. VS Code can also open notebooks directly if you prefer an editor.

Loading a CSV

import pandas as pd

trips = pd.read_csv("data/bike_trips.csv")
trips.head()

head() shows the first five rows. Always look at the data immediately after loading. You will notice things like extra header rows, odd column names or numbers stored as text.

First checks

Run these on every new dataset:

trips.shape          # (rows, columns)
trips.columns        # column names
trips.dtypes         # data type of each column
trips.info()         # types, non null counts and memory
trips.describe()     # summary statistics for numeric columns

info() is especially useful: if a column that should be fully populated has fewer non null values than there are rows, you have missing data to investigate.

Reading options that save time

trips = pd.read_csv(
    "data/bike_trips.csv",
    parse_dates=["started_at", "ended_at"],
    dtype={"start_station_id": "string", "end_station_id": "string"},
    na_values=["", "NA", "n/a"],
)
  • parse_dates converts text to proper datetimes while loading.
  • dtype sets types explicitly. Station IDs look like numbers but are identifiers, and reading them as numbers would drop leading zeros.
  • na_values tells pandas which strings mean "missing".

Other formats

  • pd.read_excel("sales.xlsx", sheet_name="2025") for Excel files.
  • pd.read_parquet("trips.parquet") for Parquet, a compressed, typed columnar format that loads much faster than CSV and keeps types intact.

A common pattern is to load a large CSV once, clean it and save it as Parquet for every later step.

Notebook hygiene

Notebooks let you run cells in any order, which can leave hidden state. Before trusting results, use Restart Kernel and Run All Cells. If the notebook does not run top to bottom, the results cannot be trusted.

← → switch lessons