Overview. We will learn about the key scientific computing packages in python: numpy.
Trigger warning. Technical content, cannot be mastered without effort.
What is numpy, a short for Numerical Python. It can be used for high performance computing and data analysis. In our case, we will just use some basic elements of numpy, but its worth knowing about because of its power and that it backs other packages we will use later. There are essentially three core features.
Scientific Computation: It provides core numerical operations like exp,log, random number generators and more!
Efficiency: it provides the most efficient data structure in python: ndarray for this type of computing. Imagine when you need to conduct calculations on more than 200k rows with 10k columns over and over again.
Data analysis: though itself does not provide very high-level data analytical function as pandas, having an understanding of it will help us use tools in pandas with less pain.
This note book will focus on the key data structure in numpy and their attributes and methods. And then we will perform basic scientific computations in numpy.
Importing the package
How do import the package? We know this. We type:
import numpy as np
This says import the package numpy then the "as np" says call it np (our alias) this just simplifies our life without having to always type numpy, we just type np. IF you're lost on this, go back to our chapter on importing packages.
Now that we have this done, let's first get to know the most important data structure in numpy.
The ndarray is the primary building block of numpy. It enables us to perform mathematical computations efficiently using similar syntax to the equivalent operations for scalar elements as we learned in python fundamental notebook 1.
So let's create an array object via array methods in numpy.