Title: Basic Operations With Numpy Array
Slug: numpy_array_basic_operations
Summary: Basic Operations With Numpy Array
Date: 2016-05-01 12:00
Category: Python
Tags: Basics
Authors: Chris Albon


In [1]:
# Import modules
import numpy as np

In [2]:
# Create an array
civilian_deaths = np.array([4352, 233, 3245, 256, 2394])
civilian_deaths


Out[2]:
array([4352,  233, 3245,  256, 2394])

In [3]:
# Mean value of the array
civilian_deaths.mean()


Out[3]:
2096.0

In [4]:
# Total amount of deaths
civilian_deaths.sum()


Out[4]:
10480

In [5]:
# Smallest value in the array
civilian_deaths.min()


Out[5]:
233

In [6]:
# Largest value in the array
civilian_deaths.max()


Out[6]:
4352