Section 1: Getting started with pandas
Setting up Jupyter and loading data
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_datesconverts text to proper datetimes while loading.dtypesets types explicitly. Station IDs look like numbers but are identifiers, and reading them as numbers would drop leading zeros.na_valuestells 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.