## How to Normalize a NumPy Matrix

In this blog post, we’ll discuss how to normalize a matrix using the popular Python library NumPy. But first things first: 👇 What is Normalization? In mathematics, normalizing refers to making something standardized or regular. Normalization of a matrix is a process of scaling the matrix so that the elements of the matrix have a … Read more

## NumPy Array Slicing – A Helpful Guide

Python NumPy array slicing is used to extract parts of data from an array. Array Slicing is often used when working with NumPy. In this article, we will go over the methods of array slicing, from basic to more advanced techniques. We will use the np.array() function to create our array examples. Before practicing any … Read more

## Python | Split String Reverse

Summary: There are three different ways to split the string and reverse it:🍎Using reversed() and join()🍎Using list slicing🍎Using numpy.flip() Minimal Example Problem Formulation 📜Problem: Given a string. How will you take a string, split it, reverse it and join it back together again using Python? Example: Let’s visualize the problem with the help of an … Read more

## Why Use NumPy Instead of List Operations?

NumPy vs Lists NumPy is an important Python library used for numerical operations and data science. Its mathematical operations on arrays are faster and more efficient than on lists. Since NumPy is primarily written in C and C++, it can perform faster operations. NumPy arrays are homogeneous arrays that can store only one type of … Read more

## Python Hex String to NumPy Array

💬 Question: How to convert a hexadecimal string such as “00-ff-ef-01-0f-0a-1a” to a NumPy array of integers [ 0 255 239 1 15 10 26]? Method 1: Hex String to List to NumPy Array You can solve this problem easily by breaking it into two easier ones: Here’s the code: Method 2: Use NumPy fromiter() … Read more

## How to Convert a NumPy Array to a Python List? (1D, 2D, 0D)

In this post, we will explore simple methods to convert NumPy arrays to lists. For example, we can utilize the Python function list() or the NumPy array method tolist().  Both ways are similar, but there are some differences to consider to choose the right one for each application.  Python Function list() The function list() accepts … Read more

## How to Convert Pandas DataFrame/Series to NumPy Array?

💬 Programming Challenge: Given a Pandas DataFrame or a Pandas Series object. How to convert them to a NumPy array? In this short tutorial, you’ll learn (1) how to convert a 1D pandas Series to a NumPy array, and (2) how to convert a 2D pandas DataFrame to an array. Let’s get started with the … Read more

## How to Print a NumPy Array Without Scientific Notation in Python

Problem Formulation » Problem Statement: Given a NumPy array. How to print the NumPy array without scientific notation in Python? Note: Python represents very small or very huge floating-point numbers in their scientific form. Scientific notation represents the number in terms of powers of 10 to display very large or very small numbers. For example, … Read more

## How to Count the Number of Unique Values in a List in Python?

Problem Statement: Consider that you have been given a list in Python. How will you count the number of unique values in the list? Example: Let’s visualize the problem with the help of an example: Given: li = [‘a’, ‘a’, ‘b’, ‘c’, ‘b’, ‘d’, ‘d’, ‘a’]Output: The unique values in the given list are ‘a’, ‘b’, ‘c’, ‘d’. … Read more

## How to Get the Length of a 2D NumPy Array

Problem Formulation and Solution Overview This article will show you how to get the length of a 2D Array in Python. These examples will generate a 2D array with two (2) arrays of five (5) random integers and return the array’s length to make it more interesting. 💬 Question: How would we write code to … Read more

## Python – Return NumPy Array From Function

Do you need to create a function that returns a NumPy array but you don’t know how? No worries, in sixty seconds, you’ll know! Go! 🚀 A Python function can return any object such as a NumPy Array. To return an array, first create the array object within the function body, assign it to a … Read more

## How to Find Min and Max Values in a 1D NumPy Array

Problem Formulation and Solution Overview This article will show you how to find the minimum and maximum values in a 1D NumPy array. To make it more interesting, these examples will generate an array of ten (10) random integers using the random.randint() function from the NumPy library and return the minimum and maximum values of … Read more