0
0
Data Analysis Pythondata~5 mins

Array shapes and dimensions in Data Analysis Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the shape of a NumPy array represent?
The shape of a NumPy array shows the size of the array in each dimension. It is a tuple where each number tells how many elements are in that dimension.
Click to reveal answer
beginner
How many dimensions does a 1D array have?
A 1D array has exactly one dimension. It looks like a simple list of values.
Click to reveal answer
beginner
What is the shape of this array? np.array([[1, 2, 3], [4, 5, 6]])
The shape is (2, 3) because there are 2 rows and 3 columns.
Click to reveal answer
beginner
What does the ndim attribute of a NumPy array tell you?
The ndim attribute tells you how many dimensions the array has. For example, 1 for 1D, 2 for 2D, and so on.
Click to reveal answer
intermediate
How can you change the shape of an array without changing its data?
You can use the reshape() method to change the shape of an array while keeping the same data.
Click to reveal answer
What is the shape of a 3D array with dimensions 4, 3, and 2?
A(4, 2, 3)
B(3, 2, 4)
C(2, 3, 4)
D(4, 3, 2)
If an array has shape (5,), what does this mean?
AIt is a 2D array with 5 rows
BIt is a 1D array with 5 elements
CIt is a 3D array with 5 layers
DIt is an empty array
Which NumPy attribute gives the number of dimensions of an array?
Ashape
Bsize
Cndim
Ddim
What happens if you try to reshape an array to a shape that does not match the total number of elements?
AIt raises an error
BIt reshapes anyway, filling missing values with zeros
CIt truncates extra elements
DIt duplicates elements to fill the shape
What is the shape of np.array([[1, 2], [3, 4], [5, 6]])?
A(3, 2)
B(2, 3)
C(6,)
D(3,)
Explain what array shape and dimensions mean in simple terms.
Think about rows and columns in a table.
You got /4 concepts.
    Describe how you can change the shape of an array and what you must be careful about.
    Imagine rearranging blocks without adding or removing any.
    You got /4 concepts.