An interactive NumPy laboratory
Explore arrays.
Understand tensors.
Type numbers and watch them become a real NumPy array — then reduce along axes, slice, reshape and broadcast, and see what NumPy does. Python runs right in your browser.
- 1Type numbers — no Python needed to start.
- 2See the ndarray — its grid, axes, shape and dtype.
- 3Change something — an axis, an index, a shape — and watch NumPy's answer.
a = shape (2, 3)
Try
Spaces or commas between values · new line = new row · blank line = new 2-D layer (3-D array).
Starting Python… (first visit downloads ≈ 15 MB, then it is cached)
1
2
3
4
5
6
- axis 0 rows · length 2
- axis 1 columns · length 3
a waiting for NumPy…
- a.shape
- (2, 3)
- a.ndim
- 2
- a.size
- 6
- a.dtype
- …
- a.itemsize
- …
- a.nbytes
- …
Chapters
- 01 Meet the ndarray Type numbers, get a NumPy array, and read its shape, ndim and size.
- 02 Shape Rearrange the same elements: reshape, flatten, ravel and transpose.
- 03 Axis What axis=0 and axis=1 really mean — and how reductions collapse an axis.
- 04 Indexing & Slicing Pick single elements, rows, columns, ranges and masks — and see exactly what you selected.
- 05 dtype Every element has the same type. See what conversions do to values and memory.
- 06 Broadcasting Combine arrays of different shapes: align from the right, stretch the 1s.
- 07 Vectorization Replace Python loops with whole-array operations — same result, far less work.
- 08 View vs copy Which operations share memory with the original array — and what happens when you write into them.
- 09 Combining arrays Join arrays with concatenate and stack, add an axis with np.newaxis, and cut them apart with split.
- 10 NumPy → PyTorch ndarray vs Tensor: converting, similarities and differences. PyTorch
- 11 PyTorch Tensor Tensor creation, shape, dtype, numel and device. PyTorch
- 12 Autograd requires_grad, the computational graph, backward and gradients. PyTorch
- 13 NumPy → pandas A DataFrame is an array with labels: dtype per column, axis, loc vs iloc, alignment. pandas