EEMI

Guided Notes

Creating Arrays, Shapes & Data Types

0-D to n-D arrays, helper functions for creating arrays, dimensions, and data types.

Dimensions

Slide 1 / 5

An array's dimensions are its levels of nesting:

โ€ข 0-D โ€” a single value: np.array(42) โ€ข 1-D โ€” a row of values: np.array([1, 2, 3]) โ€ข 2-D โ€” rows and columns (a matrix): np.array([[1, 2, 3], [4, 5, 6]]) โ€ข 3-D โ€” a stack of 2-D arrays, like an RGB image (height ร— width ร— 3 colors).

arr.ndim reports how many dimensions an array has. np.array([1, 2, 3], ndmin=3) forces extra dimensions.

โ† Introduction to NumPy