Data Analytics · Python Toolkit

Two libraries that do most of the heavy lifting.

NumPy gives you fast numbers. Pandas gives you tables. Together they cover the everyday loop of analytics — load, clean, compute, summarise.

NumPy

The number engine

A grid of numbers (the array) that runs math on whole columns at once — no loops, far faster than plain lists.

Create an array

Wrap a list to get a vectorised array.

import numpy as np
a = np.array([10, 20, 30, 40])

Math on the whole array

One operation touches every element.

a * 2          # [20 40 60 80]
a.mean()       # 25.0
a[a > 20]      # [30 40]  → filter by condition

Shape & aggregate

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]
Pandas

The table workhorse

Built on NumPy, but with labels. The DataFrame is a spreadsheet in code — named columns, mixed types, and rich grouping.

Load your data

Most analysis starts from a CSV.

import pandas as pd
df = pd.read_csv("sales.csv")
df.head()        # peek at first 5 rows

Select & filter

Pick columns by name, rows by condition.

df["price"]              # one column
df[df["price"] > 500]    # rows above 500

Clean the messy bits

Handle blanks before you trust any number.

df = df.dropna()                 # drop empty rows
df["price"] = df["price"].fillna(0)

Group & summarise

The analytics payoff — split by category, then aggregate.

df.groupby("city")["price"].mean()
# avg price per city

The everyday loop

read_csv load dropna clean filter select groupby compute NumPy math underneath