# Creating Numpy Arrays

# Import Modules import numpy as np

# Create a list regimentSize = [534, 5468, 6546, 542, 9856, 4125]

# Create a ndarray from the regimentSize list regimentSizeArray = np.array(regimentSize); regimentSizeArray

array([ 534, 5468, 6546, 542, 9856, 4125])

# What are the number of dimensions of the array? regimentSizeArray.ndim

1

# What is the shape of the array? regimentSizeArray.shape

(6,)

## Nested Lists To Multidimensional Arrays

# Create two lists regimentSizePreWar = [534, 5468, 6546, 542, 9856, 4125] regimentSizePostWar = [234, 255, 267, 732, 235, 723]

# Create a ndarray from a nested list regimentSizePrePostArray = np.array([regimentSizePreWar, regimentSizePostWar]); regimentSizePrePostArray

array([[ 534, 5468, 6546, 542, 9856, 4125], [ 234, 255, 267, 732, 235, 723]])

# What are the number of dimensions of the array? regimentSizePrePostArray.ndim

2

# What is the shape of the array? regimentSizePrePostArray.shape

(2, 6)

### Find an error or bug?

Everything on this site is available on GitHub. Head to and submit a suggested change. You can also message me directly on Twitter.