Search⌘ K
AI Features

NumPy Array Creation

Explore the basics of creating 1-D and 2-D NumPy arrays in Python. Understand how to use essential functions such as ones, zeros, empty, and arange to generate arrays for predictive data analysis. This lesson prepares you for efficient data handling and processing in your projects.

If you don’t know what an array is, please read this short article.

Creating an array

NumPy has the power to create multi-dimensional arrays beyond 2 dimensions, but for this course, we focus on 1-D and 2-D array creation.

1-D array

The following program creates a 1-D array:

Python 3.5
import numpy as np
# Creating 1-D array
n_array = np.array([1,2,3,4,5])
print(n_array)

A single list of numbers is ...