Higher Dimension
Lesson 4 of 18 in Coddy's Numpy Fundamentals course.
Numpy allows for the creation of arrays with varying dimensions, enabling the handling of data in a structured manner. Here's how:
One-dimensional Array: Represents a linear collection of elements.
one_dimension = np.array([1, 2, 3])Two-dimensional Array: Represents a matrix or a table of elements.
two_dimension = np.array([[1, 2], [3, 4]])Three-dimensional Array: Represents a collection of matrices, useful for more complex data structures.
three_dimension = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])Zero-dimensional Array: Arrays in Numpy can even be zero-dimensional, representing a single scalar value.
ary = np.array(5) # 0 DimensionChallenge
EasyCreate a function named one_dimension_higher that receives a list and converts it to an array one dimension higher.
Try it yourself
import numpy as np
def one_dimension_higher(lst):
passAll lessons in Numpy Fundamentals
2N-Dimensional Array Creation
Higher DimensionUnderstanding ShapesPopulate with Fixed ValuesNumpy TypesRangeReshape