Reshaping, Transposing, and Array Manipulation

Introduction

Engineering data rarely arrives in the shape an algorithm expects. A sensor log may come in as one long 1-D stream when you need a table of rows and columns; a matrix may need to be transposed before it can be multiplied; results from several trials may need to be joined into one block, or split back apart. NumPy handles all of this through shape manipulation: operations that rearrange how the same underlying data is presented, usually without copying or changing a single value.

In this topic you will work with reshape to change dimensions, transpose (and the .T attribute) to swap axes, flatten and ravel to collapse an array back to one dimension, hstack/vstack/concatenate and the split functions to join and separate arrays, and techniques such as squeeze, np.newaxis, and expand_dims to add or remove length-one dimensions. These tools are the connective tissue between the array creation, indexing, and linear algebra skills covered elsewhere in this module.

As you watch, pay attention to three things: whether the total number of elements is preserved (reshape requires it), whether the result is a view sharing memory with the original or an independent copy (ravel versus flatten is the classic example), and which axis an operation acts along. Keep a Python session open and retype the examples with your own small arrays — shape errors are far easier to understand once you have caused a few deliberately.

Video 1: Numpy Tutorial #10 - Reshape (Python für Data Science)

The Morpheus Tutorials · 7:17 · 2,655 views · 5y ago · captions — Watch on YouTube

About this video

A focused tutorial on np.reshape from a long-running NumPy/data science series. Based on its title and placement in the playlist, it should demonstrate converting arrays between 1-D, 2-D, and higher-dimensional shapes, the requirement that the element count match, and likely the use of -1 to let NumPy infer one dimension automatically.

Why this video

It isolates reshaping — the foundational operation of this topic — in a short, single-concept lesson, which makes it a good starting point before combining shape changes with stacking or transposing. Note that the narration is in German; the code shown on screen is standard NumPy and follows along easily, and captions can help.

Video 2: 6 Numpy Array | Ravel | Squeeze | Transpose | linspace | np.tile | Repeat

Data Insights School · 10:17 · 438 views · 4y ago · captions — Watch on YouTube

About this video

This video works through several array manipulation functions in one session: ravel for flattening, squeeze for dropping length-one dimensions, and transpose for swapping axes, alongside linspace, np.tile, and repeat. The description indicates it explicitly contrasts repeat with np.tile, which are easy to confuse.

Why this video

It covers three of our subtopics — flattening/raveling, transposing, and removing dimensions — in a single compact walkthrough, so you can see how these operations relate to each other rather than learning them in isolation.

Video 3: 7 Numpy Stacking

Data Insights School · 16:00 · 894 views · 4y ago · captions — Watch on YouTube

About this video

A dedicated lesson on joining arrays, covering vertical and horizontal stacking and the dimension-compatibility rules that stacking requires. The description notes that arrays must have matching dimensions and flags the case of mixing 2-D and 3-D arrays, which will not stack.

Why this video

Stacking is the subtopic most likely to produce confusing shape errors in practice, and this video spends its full length on the rules behind those errors rather than just the syntax.

How These Videos Support the Learning Outcomes

These three videos round out the array-handling skills the module outcomes depend on. Reshaping and transposing determine whether arrays are broadcast-compatible, so they directly support the vectorized arithmetic work in MO2, and correctly shaped 2-D arrays are a prerequisite for the matrix operations and numpy.linalg routines in MO4. Flattening, squeezing, and adding axes change how indexing and slicing behave, reinforcing MO3, while stacking and splitting let you assemble arrays built with np.array, np.arange, or np.linspace (MO1) into the larger datasets you will then summarize with descriptive statistics and evaluate functions over in MO5.

About These Videos

These videos were chosen from YouTube on October 2, 2026. Each has captions; the player turns them on. Videos on YouTube can be changed or removed — if one no longer plays, tell your instructor. If a player does not appear, use its Watch on YouTube link.