# Mohan

## Convert an PIL image to a NumPy Array in Python

In this article, we will learn how to convert an image to a NumPy Array in Python. Given an Image we need to convert it into NumPy Array in Python. Table Of Contents How the images are stored in a computer? Convert an PIL image to a NumPy Array Using pillow library and np.array() Convert […]

## Normalize a NumPy array to a unit vector in Python

In this article, we will learn how to normalize a NumPy array to a unit vector. Table Of Contents What is Normalization? What is a Unit vector? Method 1: Using unit_vector() method from transformations library Method 2: Using normalize() method from vg module. Method 3: Using linalg.norm() method from numpy module Method 4: Calculating norm

## How to print the contents of a file in Python

In this article, we will learn how to print the contents of a file in python. We will be discussing multiple approaches to print the contents of a file. The file name and its contents which we will be using in the code is as follows, File name: file.txt Contents of the file Table Of

## Calculate Euclidean distance using NumPy in Python

In this article we will learn How to calculate euclidean distance using numpy in Python. Table Of Contents What is euclidean distance? Calculate euclidean distance using sqrt() and sum() methods of numpy Calculate euclidean distance using norm() function Calculate euclidean distance using dot() Calculate euclidean distance using vdot() Calculate euclidean distance using np.linalg.multi_dot() Summary What

## How to extract a tar file in Python?

In this article, we will learn how to extract a tar file in python. we will be discussing multiple approaches to extract a tar file. Table Of Contents Introduction Extracting a tar file using extractall() in Python Extracting a tar file using extract() method Extracting a tar file using _extract_member() and getmembers() Extracting a tar

## Get indices of N maximum values in a NumPy array in Python

In this article, we will learn how to get indices of N maximum values in a NumPy array. Table Of Contents Introduction Method 1: Using argpartition() function Method 2: Using argsort() function. Method 3: Using nlargest() of heapq module. Method 4. Iterating and finding indices of n maximum values Summary Introduction Suppose we have a

## How to initialize a NumPy Array in Python?

In this article, we will learn how to initialize a NumPy Array in Python Table of Contents What is initialization? Initialize a NumPy Array by directly passing values to the array Initialize a NumPy Array by using asarray() Initialize a NumPy Array by using zeros() Initialize a NumPy Array by using ones() Initialize a NumPy

## Print NumPy Array without scientific notation in Python

In this article, we will learn how to print a numpy.array without scientific notation. Table Of Contents What is scientific notation? 1. Using set_printoptions() function and supress argument. 2. Using printoptions() function and supress argument. 3. Using set_printoptions() function and formatter argument. 4. Using array2string() function and suppress_small argument. Summary What is scientific notation? Scientific

## Matrix Vector multiplication using NumPy in Python

In this article, we will learn matrix-vector multiplication using NumPy. Table Of Contents What is a matrix in numpy and how to create it? Perform matrix-vector multiplication using numpy with dot() Perform matrix-vector multiplication using numpy with matmul() method. Perform matrix-vector multiplication using @ operator. Summary What is a matrix in numpy and how to

Scroll to Top