Introduction to Numpy

NumPy is a fundamental Python library for numerical computing. Key elements in a NumPy cheat sheet include:

  • Importing: Use import numpy as np to access NumPy functions.

  • Arrays: Create arrays with np.array([1, 2, 3]).

  • Array Operations: Perform element-wise operations like +, -, *, /, and functions such as np.sum(), np.mean(), np.std().

  • Reshape: Change the shape of arrays using np.reshape().

  • Indexing: Access elements with array[index] or slicing array[start:end].

  • Linspace and Arange: Generate ranges of values using np.linspace(start, stop, num) and np.arange(start, stop, step).

  • Random: Generate random numbers with np.random.random(size).

These features make NumPy essential for efficient data manipulation.