NumPy : Cheatsheet and Resources
Table of contents
NumPy or Numerical python is a python library used for “numerical computing” in python.
It that provides a multidimensional array object
Numpy cheatsheet
1. import numpy as np # Import numpy library
2. arr = np.array([1, 2, 3]) # Create a numpy array
3. arr.shape # Get the shape of the array
4. arr.reshape((rows, cols)) # Reshape the array
5. arr.mean() # Calculate the mean of the array
6. arr.std() # Calculate the standard deviation of the array
7. np.median(arr) # Calculate the median of the array
8. np.arange(start, stop, step) # Generate an array with a range of values
9. np.linspace(start, stop, num) # Generate an array with evenly spaced values
10. np.random.rand(rows, cols) # Generate an array with random values
11. arr + arr2 # Element-wise addition
12. arr * arr2 # Element-wise multiplication
13. np.dot(arr1, arr2) # Dot product of two arrays
14. np.linalg.inv(matrix) # Inverse of a matrix
15. arr[arr > 0] # Boolean indexing to filter array elements
Resources
Official NumPy website numpy.org
NumPy Learn numpy.org/learn
Beginners guide numpy.org/devdocs/user/absolute_beginners.h..
NumPy quickstart numpy.org/devdocs/user/quickstart.html
NumPy tutorials numpy.org/numpy-tutorials
Scientific python lectures lectures.scientific-python.org
Jupyter and Colab NumPy tutorial cs231n.github.io/python-numpy-tutorial
Books
Advance NumPy
- 100 NumPy exercises labri.fr/perso/nrougier/teaching/numpy.100/..