# numpy interview questions

## NumPy replace inf with zero

In this post, we are going to understand how to replace inf with zero in the NumPy array. The inf values are infinite values that can be positive or negative, NumPy library np.isinf() function checks element-wise positive or negative infinite values and returns a boolean array.The np. nan_to_num() function also used for replace infinite values.To …

## How to count non-nan elements in NumPy array

In this post, we are going to understand How to count non-nan elements in NumPy array for example by using numpy library function isnan(). The nan is not a number or missing value. To run the below programs Numpy must install on the system and imported it in programs using “import numpy as np” How …

## NumPy count elements by condition

In this post, we are going to learn how to count NumPy array elements by the condition in Python for example. We will use the built-in functions np.any(), np.all(), np.sum(), np.where(), np.isnan(), np.inf(), count_nonzero() of the NumPy library 1. Numpy Count elements by condition mutiple The ndarray comparison operation returns a boolean array of True …

## NumPy 2D array count unique value occurrence

In this, we are going to learn how to count the occurrence of unique values in the NumPy 2D array. The numpy library np.unique() is used to find unique values, their occurrence, and index position. 1. NumPy 2D array count unique value occurrence The np.unique() method finds unique elements in a NumPy array and returns …

## NumPy sum Specific columns

In this post, We are going to learn how to calculate the NumPy sum of Specific columns with examples of sum of numpy specific columns from a list of indices, the sum of a specific range of columns, numpy sum first column,numpy second column. Numpy sum of the last column, NumPy sum based on condition. …

## NumPy array sum based on indices

In this post, we are going to learn how to Sum NumPy array elements based on indices, the numpy library sum() function is used to sum numpy array elements. First, we have to install and import into our code. 1.NumPy array Sum based on list of indices Sometimes we have indices of numpy array as …

## Delete elements by value or condition in NumPy array

In this post, We are how to delete elements by value or condition in NumPy array by using the numpy library function np. delete().We will cover the delete element by value, delete element by index, delete element by mutiple condition, delete rows by mutiple condition, delete row in place from numpy array with examples. 1. …

## Numpy array delete row by mutiple condition

In this post, we are going to learn how to delete rows by multiple conditions in a numpy array. We are going to use np. delete() and np.where() function or np.any() or np.all() function with examples. NumPy delete function The numpy. delete() function returns a new array after deleting rows and columns along with the given axis. …

## Filter 2D NumPy array based on condition

In this post,we will learn how to Filter 2D NumPy array based on condition by using the different NumPy libaray function that includes numpy.any(),numpy.all(),nump.where(), 1.NumPy.any() to filter 2D NumPy array based on condition The np.any() method is used to validate a condition whether any element of the numpy array is returning True. In the below …

## How to filter numpy array based on list of indices

In this post, we are going to understand How to filter a numpy array based on a list of indices by using the numpy function take() filter the numpy array based on indices. 1. filter numpy array based on a list of indices row-wise The np. take() function returns the elements of the numpy array …