Net-informations.com

NumPy - Numerical Python

NumPy (stands for Numerical Python ) is a fast and versatile library for the Python programming language, adding support for large, N-dimensional arrays and matrices, along with a large collection of comprehensive mathematical functions to operate on these multidimensional arrays . NumPy was created in 2005 by Travis Oliphant. It is one of the fundamental package for scientific computing in Python. NumPy arrays are stored at one continuous place in memory unlike Python lists (which can grow dynamically ), so processes can access and manipulate them very fast and efficiently.


numpy python

How To Install NumPy

Prerequisites

  1. Python installed on your system

The easiest way to install NumPy is by using Pip Installs Packages (Pip). If you don't have Pip installed on your system, you need to set up the package manager that corresponds to the version of Python you have.

With Pip set up, you can use its command line for installing NumPy .

Importing the NumPy module

If you have large amounts of calls to NumPy functions , it can become tedious to write numpy.x() over and over again. Instead, it is common to import under the briefer name np.

Create a NumPy array

Creating a 1-D NumPy array with continuous 9 values.

Check the type of NumPy array

Create a 2-D NumPy array

Creating a 2-D NumPy array with 2 rows and 4 columns.


numpy 2d array

Create a 3-D NumPy array

Creating a 3-D NumPy array with 2 rows, 3 columns and 4 depth.

NumPy Array Shape

The shape property of a NumPy array returns a tuple with the size of each array dimension.

1-D NumPy Array shape

Here npArr is a 1-D NumPy array so the shape of the array is (9,), this means that the array has continuous 9 values only.

2-D NumPy Array shape

Here npArr is a 2-D NumPy array so the shape of the array is (2, 4), this means that the array has 2 rows and 4 columns dimensions.

3-D NumPy Array shape

Here npArr is a 3-D NumPy array so the shape of the array is (2, 3, 4), this means that the array has 2 rows, 3 columns and 4 depth dimensions.










net-informations.com (C) 2021    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.
SiteMap  | Terms  | About