DEV Community

Punitha
Punitha

Posted on

Introduction of NumPy

What is NumPy?

  • NumPy (Numerical Python) is a Python library used for numerical and scientific computing.

  • It provides a powerful data structure called an array, which is useful for storing and processing numerical data.

Why Use NumPy?

  • It works efficiently with numerical data.

  • It provides powerful array operations.

  • It supports multi-dimensional arrays.

  • It provides mathematical functions.

  • It is widely used in Data Science and Machine Learning.

Installing NumPy

Step 1:

  • Open Command Prompt or VS code Terminal

Step 2:

Run:

pip install numpy
Enter fullscreen mode Exit fullscreen mode

Step 3:

  • Wait until the installation is completed.

Step 4: Import NumPy

  • After installation, import NumPy into your Python program.
import numpy as np
Enter fullscreen mode Exit fullscreen mode
  • numpy is the library name.
  • np is the commonly used alias for NumPy.

Step 5: Check NumPy Version

print(np.__version__)
Enter fullscreen mode Exit fullscreen mode

NumPy Array Attributes

  • NumPy provides useful attributes to understand an array.
  • Size - size tells the total number of elements.
  • ndim - ndim tells the numbers of dimensions.
  • dtype - dtype tells the data type of the elements.
  • itemsize - itemsize tells how many bytes are used by each element.
  • shape - shape tells the size of each dimension.

Top comments (0)