After this lesson, you will be able to: Use pandas and NumPy for basic data manipulation, plot results with matplotlib, and know when to reach for them vs plain Python.
Pandas + NumPy are how Python eats data, and matplotlib is how you chart it. Just enough to be dangerous + know when to escape to them.
Array-based numeric computing. 100x faster than Python lists for math.
import numpy as npa = np.array([1, 2, 3, 4, 5])print(a * 2) # [2 4 6 8 10], vectorized; no loopprint(a.mean(), a.std(), a.sum())# 2D arraym = np.array([[1, 2], [3, 4]])print(m.shape) # (2, 2)print(m @ m) # matrix multiply# Random + seedingrng = np.random.default_rng(seed=42)samples = rng.normal(loc=0, scale=1, size=1000)
DataFrame = a programmable spreadsheet.
import pandas as pd# Load CSVdf = pd.read_csv("sales.csv", parse_dates=["date"])# Inspectdf.head()df.describe()df.dtypes# Filter + selectrecent = df[df["date"] >= "2026-01-01"]emails = df[["name", "email"]]# Group + aggregateby_region = df.groupby("region")["revenue"].agg(["sum", "mean", "count"])# Joinorders = pd.read_csv("orders.csv")merged = df.merge(orders, on="user_id", how="left")# Write backmerged.to_csv("out.csv", index=False)merged.to_parquet("out.parquet") # binary, smaller, faster
matplotlib is the baseline plotting library. pandas plots through it directly, so a quick chart is one method call. Keep this light; the AI/ML track goes deeper into visualization.
import matplotlib.pyplot as pltimport pandas as pddf = pd.read_csv("sales.csv", parse_dates=["date"])# pandas plots through matplotlib: one call for a quick line chartby_month = df.groupby(df["date"].dt.to_period("M"))["revenue"].sum()by_month.plot(kind="line", title="Revenue by month")plt.ylabel("Revenue (USD)")plt.tight_layout()plt.savefig("revenue.png", dpi=150) # save for a reportplt.show() # or display interactively# Drop to the matplotlib API directly when you need controlfig, ax = plt.subplots(figsize=(8, 4))ax.bar(by_region.index, by_region["sum"])ax.set_title("Revenue by region")ax.set_xlabel("Region")ax.set_ylabel("Revenue (USD)")fig.savefig("by_region.png")# Common next steps: seaborn (prettier statistical charts on top of matplotlib),# or plotly for interactive charts.
Tabular data with > ~10K rows: pandas. Numeric arrays, math, ML pre-processing: NumPy. Quick charts from a DataFrame: df.plot(...) (matplotlib under the hood); save with plt.savefig for reports. Small CSV (< 1K rows), one-off scripts: csv + dataclasses might be cleaner. Streaming / large data: polars (pandas alternative, 10x faster) or DuckDB.
Iterating with `for i, row in df.iterrows()`. SLOW. Vectorize with column ops. Using `apply()` to do what a vectorized op can. Floating CSV index column from one tool to another. Always to_csv(index=False) unless meaningful. Mixing dtypes (string in a numeric column). Pandas degrades performance.
Pick the honest answer.
Sign in and purchase access to unlock this lesson.