-
Pandas Basics 5
-
Lecture1.1
-
Lecture1.2
-
Lecture1.3
-
Lecture1.4
-
Lecture1.5
-
-
Data Transformations 6
-
Lecture2.1
-
Lecture2.2
-
Lecture2.3
-
Lecture2.4
-
Lecture2.5
-
Lecture2.6
-
-
Statistics 4
-
Lecture3.1
-
Lecture3.2
-
Lecture3.3
-
Lecture3.4
-
-
Reading and Writing Data 3
-
Lecture4.1
-
Lecture4.2
-
Lecture4.3
-
-
Joins 5
-
Lecture5.1
-
Lecture5.2
-
Lecture5.3
-
Lecture5.4
-
Lecture5.5
-
-
Grouping 4
-
Lecture6.1
-
Lecture6.2
-
Lecture6.3
-
Lecture6.4
-
-
Introduction to Numpy 4
-
Lecture7.1
-
Lecture7.2
-
Lecture7.3
-
Lecture7.4
-
-
Randomness 2
-
Lecture8.1
-
Lecture8.2
-
-
Numpy Data Functionality 1
-
Lecture9.1
-
Introduction
Numpy Introduction¶
Numpy is a library that you will often use with pandas for achieving data science goals. It serves many similar purposes but has different features and abilities that often complement pandas. For example, many linear algebra operations can be achieved with great ease using numpy. These kinds of operations are not ones you want to do with native python data types because the speed is just not the same. Numpy has optimization under the hood that makes it run in fractions of what it takes for regular python.
Numpy Arrays¶
The basic type of data for numpy is an array, which is similar to lists in python but with a rich set of numpy features you can use for them. To create a numpy array, you just call np.array() and pass in the list of data you have.
import numpy as np
#Create a basic numpy array
ar1 = np.array([1, 2, 3])
print(ar1)
[1 2 3]
Indexing a one dimensional array works the same in numpy as with basic python lists, for example, to get the first element, or the first two elements...
#Basic indexing
print(ar1[0])
print(ar1[:2])
1
[1 2]