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.
list = [1,2,3,'hi',[2,3,4]]
# mix data type list
# list is collection of objects
dictionary = {'k1':'v1' , 'k2':'v2'}
# Key value pair
tuple = (1,2,3)
# tuples are fixed values and cannot be assigned
set = {1,2,3,1,2,1,2,1,2,1,2,1,3}
# set can have only unique values
# for above result is only 1,2,3
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
7.3 Functions
Can have defaults