Tools 1.2The video for this lesson is on its way.
Everything else is ready: study the parts, the key terms and the quiz below.
- Part 11Loading an array, and reading its shape
- Part 22Reshaping to a grid: shape, ndim, size and len
- Part 33Reshape changes the reading, not the buffer
- Part 44dtype, itemsize and nbytes
- Part 55Fixed width: int8, astype and silent wraparound
- Part 66Creating arrays without data: zeros, ones, arange and linspace
- Part 77Recap and your challenge
Tools 1.2Code walkthrough7 parts
Shape, dtype and Reshaping
Read any array's shape and dtype, and reshape without copying.
Loading your progress…Next: 1.3 Indexing, Slicing and Masks
In this lesson7 parts
- 01Loading an array, and reading its shape
- 02Reshaping to a grid: shape, ndim, size and len
- 03Reshape changes the reading, not the buffer
- 04dtype, itemsize and nbytes
- 05Fixed width: int8, astype and silent wraparound
- 06Creating arrays without data: zeros, ones, arange and linspace
- 07Recap and your challenge
Quiz 5 questions
Answer each one in your head, or on paper, before you check it. Getting one wrong here is how the lesson sticks.
- 01
salesholds 2,920 revenue values in one flat line. What doessales.reshape(-1, 8).shapegive? - 02
What does
np.zeros(3)hold — integers or decimal numbers? - 03
How many values does
np.arange(0, 1, 0.1)give you? - 04
Our
unitscolumn runs from57to564. You convert it withunits.astype(np.int8)to save memory. What happens? - 05
revenue_gridhasshape (365, 8)anddtype('float64'). What isrevenue_grid.nbytes, and why?