np.diff: How to Find Difference Between Numbers in Array
The np.diff() is a numpy array function that finds the difference numbers in an array. The np.diff() function can be applied to a single array and multiple arrays. If a single array is passed then the difference is found by res = arr – arr.…
np.unique: How to Get Unique Values in NumPy Array Python
The np.unique() is a numpy library function that returns all the unique elements in the array. The returned array does not contain duplicate elements. The np.unique() function can be used to remove duplicates. It returns all the elements…
np.sin: How to Use numpy sin() Function in Python
The np.sin() is a numpy library function that generates the sine value for the angle passed inside the function.
Syntax
numpy.sin(x, /,out=None,*,where=True, casting='same_kind', order='K', dtype=None, subok=True) = <ufunc…
np.hstack: How to Stack Array in Horizontal Direction
The np.hstack() is a numpy library function that stacks the arrays horizontally. Hstack stands for the horizontal stack. The resulting array will be single-dimensional if two single-dimensional arrays are horizontally stacked using a…
np.concatenate: How to Join Numpy Array in Python
The np.concatenate() is a numpy library function that joins two numpy arrays into a single numpy array. There are two types of concatenating the arrays. One is by concatenating using the axis 0, that is, by adding the second array at the…
np.linspace: How to Create Evenly or Non-Evenly Spaced Arrays
The np.linspace() is a numpy function that returns the sequence of numbers in a specified interval. The np.linspace() function mainly requires the start end and the number of splits. The np.linspace() function returns the n numbers between…
np.random.normal: How to use numpy random normal
The np.random.normal() is a numpy function used to get random numbers for the normal distribution. The normal distribution is often called the bell curve because of its shape. As the shape of the normal distribution graph looks like the…
np.random.randint: Random Numbers in Numpy
Generating random numbers is easy in Python because it provides a random and numpy package. When working with machine learning projects, you need to create a basic data set that consists of random integers and numbers. Using…
np.pad: How to Use numpy pad() Function in Python
The np.pad() is a numpy library function used for padding the arrays. The padding is a process in which the array is appended with some values at the beginning and end.
Syntax
numpy.pad(array, pad_width, mode = 'constant', **kwargs)…
np.eye: Create 2D Array with Ones on the Diagonal and Zeros
The np.eye() function returns a 2D array with 1’s as the diagonal and 0’s elsewhere with specified size in Python. It returns an array where all items are equal to zero, except for the k-th diagonal, whose values are equal to one.
The…
How to Convert Python String to List of Characters
When you are working on a project, you come across a task in which you have to create the characters of a list based on the string. You can create a list based on an input string from either an API or a processed string.
Python String to…