Reshape Arrays with numpy.reshape()
📖 Scenario: Imagine you work in a bakery that tracks daily sales of different types of bread. The sales data is collected as a single list of numbers, but you want to organize it into a table showing sales per day and bread type.
🎯 Goal: You will create a numpy array from a list of sales numbers, then reshape it into a 2D array with rows as days and columns as bread types. Finally, you will print the reshaped array to see the organized sales data.
📋 What You'll Learn
Use numpy to create and reshape arrays
Create a 1D numpy array with exact sales data
Define a new shape as a tuple
Use numpy.reshape() to change the array dimensions
Print the reshaped array
💡 Why This Matters
🌍 Real World
Reshaping arrays is useful when you want to organize flat data into tables or grids, like sales data per day and product.
💼 Career
Data scientists often reshape data to prepare it for analysis or visualization, making this skill important for cleaning and structuring data.
Progress0 / 4 steps