7 NumPy

NumPy (or Numpy) is a Linear Algebra Library for Python, the reason it is so important for Data Science with Python is that almost all of the libraries in the PyData Ecosystem rely on NumPy as one of their main building blocks.

Numpy is also incredibly fast, as it has bindings to C libraries. For more info on why you would want to use Arrays instead of lists, check out this great StackOverflow post.

Important aspects of Numpy: vectors,arrays,matrices, and number generation.

7.1 Numpy Arrays

Arrays are used to represent Vectors and Matrices.

Vector 1-d

Matrix 2-d (can be 1X1 as well)

7.1.1 arange

we can build array using this.

Notes on Python as I learn and improve my understanding.

7.2 Differences

Any String is by default a list of characters.

##Data Structures

Python’s in built data sets are list, dict and sets.

All above can be accessed using [] and index. index from 0 and end not included [0:3] gives 0,1,2 and not 3

[0:-2] all but last two.

List Comprehension

Defines list in one line, for eg, to find squares

sqr = [x**2 for x in range(5)]

This gives list with squares of numbers 0 to 4