NumPy

NumPy


NumPy is a python library which allows us to efficiently use the memory. It is mainly work on the n-dimensional array. To work on any data science NumPy is the initial step. It is also very helpful for Machine Learning.

Why NumPy

  • It manages the memory efficiently.
  • It works on the n-dimensional array.
  • It uses the algorithms written in C that make it fast and completed in nanoseconds rather than the seconds.
  • Provides number of function which is very useful in the programs.

Installing NumPy

To install NumPy we will use powercell,

  • Open Powercell
  • Type the code "pip install NumPy" and press the enter.
  • Your installation will be started.

How to use

You can use any text editor like Jupyter, colab, etc for programing.

To use the NumPy in the program we need to import it by using the code:

import numpy as np

here, we are defining the numpy as np to ensure the we don't need to type the numpy again and again.


Getting Started with Array

1-dimensional array

Defining the array is very easy, just use 

Syntax: np.array([elements],dtype="data_type")

2-dimensional array

Syntax: np.array([[elements][elements]],dtype="data_type")

Shape function

This function will give the shape of the array,

Syntax: array_name.shape()

We can also reshape any give array,

Syntax: array_name.reshape(x,y)

Arange function

This function will help in creating an array which is in the range of some number,

Syntax: np.arange(size)

Linshape function

It is a very effective function which is used to get an array having equal separation in each element in the given range.

Syntax: np.linspace(start, end, size)

Basic statistics functions

These include maximum, minimum, average


For more function please visit the official site using the below link: Click here


PRIYANSHI VASHISTHA (2019-2023)

Computer Science Department
KIET Group of Institutions

Comments

Popular posts from this blog

QUANTUM STORAGE & MEMORY

QUANTUM COMPUTING: CAN FIGHT CLIMATE CHANGE

BLOCKCHAIN: HOW IT WORKS AND WHY SO POPULAR