← NumPy
Lesson 3 of 3
Reshaping and filtering
Watch, read the card, then practise. Reshaping · Filtering with conditions · Joining arrays
The video for this lesson is being recorded.
Meanwhile, the notes below and the 60-second cards cover the same ideas.
Practise this topicReshaping
reshape changes an array's shape without changing its values.
Remember: The total number of values must stay the same.
Filtering with conditions
A condition on an array gives True/False for each value. Use it to pick only the matching values.
Remember: Use & and |, not 'and' and 'or', with arrays.
Joining arrays
Join arrays end to end with concatenate, or stack them as rows or columns.
Remember: vstack = on top. hstack = side by side.
Try the example in Code Lab
import numpy as np a = np.arange(6).reshape(3, -1) print(a.shape, a.tolist())