Recall & Review
beginner
What does reshaping an array mean in numpy?
Reshaping an array means changing its shape or dimensions without changing its data. For example, turning a list of 6 elements into a 2x3 matrix.
Click to reveal answer
beginner
Why is reshaping arrays important in data science?
Reshaping helps organize data to fit the needs of different algorithms or operations. It makes data easier to analyze, visualize, or feed into models.
Click to reveal answer
beginner
What happens if you try to reshape an array to a shape that doesn't match its total elements?
Numpy will give an error because the total number of elements must stay the same when reshaping.
Click to reveal answer
intermediate
How does reshaping help when working with images in numpy?
Images are often stored as 3D arrays (height, width, color channels). Reshaping can flatten or change these dimensions to prepare images for processing or machine learning.
Click to reveal answer
beginner
What numpy function is used to reshape arrays?
The function is numpy.reshape(). It takes the new shape as an argument and returns a reshaped array.
Click to reveal answer
What must stay the same when reshaping a numpy array?
✗ Incorrect
When reshaping, the total number of elements must remain the same to avoid errors.
Which numpy function is used to change the shape of an array?
✗ Incorrect
numpy.reshape() is the correct function to change the shape of an array.
Why might you reshape a 1D array into a 2D array?
✗ Incorrect
Reshaping to 2D helps organize data for operations like matrix multiplication.
What error occurs if reshaping tries to change the total number of elements?
✗ Incorrect
A ValueError is raised when the new shape does not match the total number of elements.
How can reshaping help in machine learning?
✗ Incorrect
Machine learning models often require input data in specific shapes; reshaping helps prepare data correctly.
Explain why reshaping arrays is useful when preparing data for analysis or machine learning.
Think about how data needs to fit into models or visualizations.
You got /4 concepts.
Describe what happens if you try to reshape a numpy array into a shape that does not match its total number of elements.
Consider the rule about total elements in reshaping.
You got /3 concepts.