Numpy is a fundamental package for scientific computing with Python. It provides support for large, multi-dimensional arrays and matrices, along with a collection of mathematical functions to operate on these arrays.

Installation

To install Numpy, you can use pip:

pip install numpy

Basic Usage

Here's a simple example of how to use Numpy:

import numpy as np

# Create a 1D array
a = np.array([1, 2, 3, 4])

# Create a 2D array
b = np.array([[1, 2], [3, 4]])

# Access elements
print(a[0])  # Output: 1
print(b[1, 0])  # Output: 3

# Modify elements
b[1, 0] = 5
print(b)  # Output: [[1 2] [3 5]]

Advanced Features

Numpy offers a wide range of advanced features, such as:

  • Broadcasting: Automatically expands the dimensions of arrays to match the dimensions of other arrays during arithmetic operations.
  • Slicing: Extracting parts of arrays.
  • Indexing: Accessing elements of arrays using indices.
  • Sorting: Sorting arrays in ascending or descending order.

Further Reading

For more information on Numpy, you can visit the official documentation: Numpy Documentation

Useful Links

[center] Numpy Logo [center]