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 …

NumPy replace inf with zero Read More »

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 count elements by condition Read More »

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 sum Specific columns Read More »