T-S-Brown
9/16/2017 - 4:50 PM

Numpy basics

Overview of basics of Numpy

# Basics of numpy

import numpy as np

np.array() # The argument is typically a list []

# To square a number use ** NOT ^

x = np.array([1,2,3,4,5,6,7,8,9,10])

x > 4 # Returns a list of boolean values True or False
x[x > 4] # Returns the values where the condition is True


# Key functions
np.mean()
np.median()
np.corrcoef()
np.sum()
np.sort()

np.random.normal() # Takes 3 args - mean, sd, n