0
0
Data Analysis Pythondata~15 mins

Array shapes and dimensions in Data Analysis Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Understanding Array Shapes and Dimensions
📖 Scenario: Imagine you work at a small bakery that tracks daily sales of different types of bread. You want to organize this sales data in arrays to better understand the shape and size of your data.
🎯 Goal: You will create arrays representing sales data, check their shapes and dimensions, and print these details to understand how data is structured in arrays.
📋 What You'll Learn
Create a 1D array with daily sales numbers
Create a 2D array with sales of different bread types over several days
Use variables to store array shapes and dimensions
Print the shape and dimension of each array
💡 Why This Matters
🌍 Real World
Arrays are used to store and organize data like sales, temperatures, or images in rows and columns.
💼 Career
Knowing array shapes and dimensions is essential for data scientists and analysts to prepare data for analysis and machine learning.
Progress0 / 4 steps
1
Create a 1D array for daily sales
Import numpy as np and create a 1D array called daily_sales with these exact values: 10, 15, 7, 12, 9.
Data Analysis Python
Need a hint?

Use np.array() to create the array with the given list of numbers.

2
Create a 2D array for sales of bread types
Create a 2D array called bread_sales using np.array() with these exact values: [[5, 3, 2], [7, 8, 4], [6, 5, 3]]. Each inner list represents sales of three bread types for one day.
Data Analysis Python
Need a hint?

Use np.array() with a list of lists to create a 2D array.

3
Get shapes and dimensions of the arrays
Create variables daily_shape and daily_dim to store the shape and number of dimensions of daily_sales. Similarly, create bread_shape and bread_dim for bread_sales. Use the .shape and .ndim attributes.
Data Analysis Python
Need a hint?

Use array.shape to get the shape and array.ndim to get the number of dimensions.

4
Print the shapes and dimensions
Print the variables daily_shape, daily_dim, bread_shape, and bread_dim each on its own line in this exact order.
Data Analysis Python
Need a hint?

Use print() to show each variable on its own line.