NumPy, Pandas, SciPy & Django Intros
NumPy provides fast numeric arrays (ndarray) and math operations on whole arrays at once.
NumPy — intro
NumPy provides fast numeric arrays (ndarray) and math operations on whole arrays at once.
Install: pip install numpy. Foundation for Pandas, SciPy, and ML libraries.
Real-life example: NumPy is a spreadsheet engine — multiply entire columns in one step, not cell by cell.
import numpy as np
arr = np.array([1, 2, 3, 4])
print(arr * 2)
print(arr.mean())Pandas — intro
Pandas adds DataFrame tables — like Excel in Python. read_csv(), head(), describe() explore data.
Essential for data cleaning, analysis, and ML preprocessing.
Real-life example: Pandas is a smart ledger — rows are records, columns are fields, filters are one line.
import pandas as pd
data = {"name": ["A", "B"], "score": [88, 92]}
df = pd.DataFrame(data)
print(df)
print(df["score"].mean())SciPy — intro
SciPy builds on NumPy with scientific algorithms — optimization, statistics, signal processing.
Use scipy.stats for distributions and scipy.optimize for finding minima.
Real-life example: SciPy is the lab equipment room — advanced instruments built on NumPy's workbench.
from scipy import stats
sample = [2, 4, 4, 4, 5, 5, 7, 9]
print(stats.mode(sample, keepdims=True))Django — intro
Django is a full Python web framework — URLs, views, templates, ORM, admin panel.
Install: pip install django. django-admin startproject mysite starts a new site.
Real-life example: Django is a prefab house kit — walls, plumbing, and wiring included for web apps.
# views.py (concept)
from django.http import HttpResponse
def home(request):
return HttpResponse("Hello from Django!")