Search⌘ K
AI Features

NumPy Basics - Creating NumPy Arrays and Array Attributes

Explore creating NumPy arrays from lists and scratch, and understand essential array attributes such as dimensions, shape, size, and data type to work efficiently in data science.

1. Creating Arrays

There are two ways to create arrays in NumPy:

a. Arrays From Lists

The first step when working with packages is to define the right “imports”. We can import NumPy like so:

import numpy as np

Notice that np is the standard shorthand for NumPy.

There are multiple ways to create arrays. Let’s start by creating an array from a list using the np.array function.

We can create a one-dimensional (1D) array from a list by passing the list ...