NumPy TutorialLesson 4Free preview
NumPy Creating Arrays
This lesson is part of NumPy · All levels
Summary
NumPy provides many ways to create an array: from a list with np.array, an array containing zero or one with np.zeros and np.ones, as well as a sequential array with np.arange and np.linspace. These functions facilitate the initialization of a blank matrix or value grid for calculation. You can also define the data type by the dtype parameter.
Key points
- Np.zeros and np.ones make an array filled with zero or one with a certain shape.
- Np.arange(start, stop, step) makes an array sequential with step distance.
- Np.linspace(start, stop, num) divides the range into num dots of equal distance.
- The dtype parameter determines the data type of the array element.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.