Title: Numpy Array Basics
Slug: numpy_array_basics
Summary: Numpy Array Basics
Date: 2016-05-01 12:00
Category: Python
Tags: Basics
Authors: Chris Albon
In [1]:
# Import modules
import numpy as np
In [2]:
# Create a list
battle_deaths = [3246, 326, 2754, 2547, 2457, 3456]
battle_deaths
Out[2]:
In [3]:
# Create an array from numpy
deaths = np.array(battle_deaths)
deaths
Out[3]:
In [4]:
# Create an array of zeros
defectors = np.zeros(6)
defectors
Out[4]:
In [5]:
# Create a range from 0 to 100
zero_to_99 = np.arange(0, 100)
zero_to_99
Out[5]:
In [6]:
# Create 100 ticks between 0 and 1
zero_to_1 = np.linspace(0, 1, 100)
zero_to_1
Out[6]: