A repeatable NumPy workflow: create → inspect (shape, dtype) → transform (vectorized) → aggregate → validate → hand off to Pandas or ML.
Inspect first
arr.shape— dimensionsarr.dtype— element typearr.ndim— number of axesarr.size— total element count
Shape bugs cause silent wrong answers—always print shape before heavy math.
Prefer vectorization
Replace Python loops with ufuncs and axis parameters. Loops on large arrays are a performance smell.
Reproducible randomness
import numpy as np
rng = np.random.default_rng(42)
sample = rng.normal(0, 1, size=5)
print(sample)
Next steps in this track
Modules 02–05 cover creation through advanced memory. Module 06 previews Pandas and SciPy; module 07 prepares interviews and production habits.
Important interview questions and answers
- Q: Why print shape?
A: Catches dimension mismatches before broadcasting or matmul errors. - Q: default_rng vs legacy random?
A: NumPy recommends Generator API (default_rng) for better statistical properties.
Self-check
- List four inspect attributes for any ndarray.
- What is the recommended random API in modern NumPy?
Challenge
Set RNG seed
- Run the workflow lesson code.
- Re-run with a different
default_rngseed and compare output.
Done when: you understand reproducible random arrays.
Interview prep
- Inspect first?
Print shape, dtype, ndim before transforms—catches silent bugs.
- RNG?
Use np.random.default_rng(seed) for reproducible experiments.