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

  1. Official NumPy website numpy.org

  2. NumPy Learn numpy.org/learn

  3. Beginners guide numpy.org/devdocs/user/absolute_beginners.h..

  4. NumPy quickstart numpy.org/devdocs/user/quickstart.html

  5. NumPy tutorials numpy.org/numpy-tutorials

  6. medium.com/better-programming/numpy-illustr..

  7. Scientific python lectures lectures.scientific-python.org

  8. Jupyter and Colab NumPy tutorial cs231n.github.io/python-numpy-tutorial

Books

  1. web.mit.edu/dvp/Public/numpybook.pdf

  2. labri.fr/perso/nrougier/from-python-to-numpy

Advance NumPy