SciPy builds on NumPy with scientific algorithms: statistics, optimization, signal processing, sparse linear algebra, and integration.
Division of labor
- NumPy — ndarray, basic linalg, random
- SciPy —
scipy.stats,scipy.optimize,scipy.sparse
Conceptual example (local)
# Local only — requires scipy
# from scipy import stats
# stats.ttest_ind(sample_a, sample_b)
import numpy as np
a = np.array([1, 2, 3])
b = np.array([2, 3, 4])
print('NumPy mean diff:', a.mean() - b.mean())
When to reach for SciPy
Hypothesis tests, curve fitting, sparse matrices, distance metrics on large datasets—after you're comfortable with ndarray operations.
Important interview questions and answers
- Q: scipy.sparse?
A: Stores large mostly-zero matrices efficiently—graphs, NLP features. - Q: stats module?
A: Distributions, tests, and descriptive stats beyond basic NumPy.
Self-check
- Name two SciPy submodules.
- What track covers SciPy in depth?
Tip: Reach for SciPy when NumPy linalg is not enough.
Interview prep
- When SciPy?
Hypothesis tests, optimize, sparse LA beyond NumPy basics.
- stats module?
Distributions and statistical tests.