NumPy and numerical arrays
An array stores measurements in a shape such as samples by features.
Loading video…
An array stores measurements in a shape such as samples by features. Indexing selects positions; vectorized arithmetic applies one operation across values. Broadcasting combines compatible shapes, but a silently wrong shape can pair the wrong samples. Inspect shape before computing a summary along an axis.
Worked example
A 3 by 2 expression matrix has three samples and two genes. matrix.mean(axis=0) gives two gene means; matrix.mean(axis=1) gives three sample means.