NumPy gives you fast numbers. Pandas gives you tables. Together they cover the everyday loop of analytics — load, clean, compute, summarise.
A grid of numbers (the array) that runs math on whole columns at once — no loops, far faster than plain lists.
Wrap a list to get a vectorised array.
import numpy as np
a = np.array([10, 20, 30, 40])
One operation touches every element.
a * 2 # [20 40 60 80]
a.mean() # 25.0
a[a > 20] # [30 40] → filter by condition
Reshape into rows/columns and reduce along an axis.
m = a.reshape(2, 2) # [[10 20],[30 40]]
m.sum(axis=0) # column totals → [40 60]
Built on NumPy, but with labels. The DataFrame is a spreadsheet in code — named columns, mixed types, and rich grouping.
Most analysis starts from a CSV.
import pandas as pd
df = pd.read_csv("sales.csv")
df.head() # peek at first 5 rows
Pick columns by name, rows by condition.
df["price"] # one column
df[df["price"] > 500] # rows above 500
Handle blanks before you trust any number.
df = df.dropna() # drop empty rows
df["price"] = df["price"].fillna(0)
The analytics payoff — split by category, then aggregate.
df.groupby("city")["price"].mean()
# avg price per city