Practical solutions

Python NumPy Howtos How-To Guides

Solve the problem. Keep building. Collection of Python NumPy how-to articles

Find the answer you need

Browse practical solutions, grouped by the task you're working on.

__COUNT__ entries on this page

How to Get Number of Rows in NumPyThe array.shape property can be used to determine the number of rows and columns in a NumPy array in Python. How to Append to Empty Array in NumPyIn this article, we will discuss the various methods that can be used to append new rows to an empty NumPy array in Python. How to Save and Load NumPy Array in PythonThere are 3 methods to save and load a NumPy array in Python, the numpy.savetxt() and numpy.loadtxt() functions, the numpy.tofile() and numpy.fromfile() functions, and the numpy.save() and numpy.load() functions. How to Calculate the Mode of Array in NumPyThere are many ways to calculate the mode of array in NumPy, and we are going to discuss them all in this article. How to Slice 2D Array in NumPyThere are several methods that we can utilize if we want to slice a 2-dimensional sub-array from a 2-dimensional array in Python. These methods include array indexing and numpy.ix_() function How to Replace Values in NumPyThere are three main methods that can be used to replace values inside a NumPy array in Python, the numpy.clip() function, the numpy.minimum() function, and the indexing method. How to NumPy Shuffle Two ArraysThere are three main methods that can be used to shuffle two corresponding arrays in Python, the sklearn.utils.shuffle() function, the numpy.random.shuffle() function, and the numpy.random.permutation() function. How to Get Combinations of Two Arrays in NumPyThere are three main methods that can be used to find the cartesian product of two NumPy arrays in Python, the itertools.product() function, the numpy.meshgrid() function, and the for-in method. How to Divide Matrix by Vector in NumPyThere are three main methods that can be used to divide a matrix by a vector in Python, the broadcasting method, the transpose method, and the numpy.reshape() function. How to Shift Array in Python NumPyThere are three main methods that can be used to shift an array in Python, the numpy.roll() function, the array slicing method, and the shift() function in scipy library. How to Implement Bernoulli Distribution Using Python NumPyThis tutorial discusses what the Bernoulli distribution is and how to implement it in Python using NumPy. How to Iterate Over Rows of a Numpy Array in PythonThis tutorial discusses how to iterate over rows of a NumPy array in Python. How to Convert Datetime64 to Datetime.Datetime or Timestamp in NumPyThis article aims to demonstrate how to convert data between numPy.datetim64, datetime.datetime and Timestamp. How to Use Axis Argument to Manipulate a NumPy Array in PythonThis article explains how to work with NumPy axis arguments and see what an axis is in NumPy. We will also learn how to use an axis argument as a powerful operation to manipulate a NumPy array in Python quickly. Element-Wise Multiplication in NumPyThis tutorial demonstrates how to perform the element-wise matrix multiplication in Python numpy.where() Multiple ConditionsThere are 4 methods that can be used to specify multiple conditions inside the numpy.where() function in Python, the & operator, the | operator, the numpy.logical_and() function, and the numpy.logical_or() function. NumPy Magnitude in PythonThere are three main methods that can be used to find the magnitude of a vector in Python, the numpy.linalg.norm() function, the numpy.dot() function, and the numpy.einsum() function. NumPy Array EqualThere are 4 methods that can be used to carry out element-wise equality comparison on NumPy arrays in Python, the == operator, the numpy.array_equal() function, the numpy.equiv() function and the numpy.allclose() function. NumPy PaddingThis tutorial discusses how to pad a numpy array in Python. Natural Log in PythonThe log() function in the NumPy package can be used to calculate the natural log of a number in Python. NumPy Mask 2d ArrayWe go to learn with this explanation about what is the mask or Boolean array. We also go to learn how to create a 2d mask with Python logical operators and NumPy logical function in Python. NumPy Confidence IntervalThis tutorial discusses what is the Confidence Interval and how to implement it in Python using NumPy. numpy.newaxis MethodThe numpy.newaxis can be used to add a new dimension to a NumPy array in Python. One-Hot Encoding on NumPy Array in PythonThis tutorial demonstrates how to perform one-hot encoding on a numpy array in python