AmitDiwan has Published 11360 Articles

Convert an array of datetimes into an array of strings passing units in Python

AmitDiwan

AmitDiwan

Updated on 28-Feb-2022 06:19:37

233 Views

To convert an array of datetimes into an array of strings, use the numpy.datetime_as_string() method in Python Numpy. The method returns an array of strings the same shape as the input array. The first parameter is the array of UTC timestamps to format. The "units" parameter sets the datetime unit ... Read More

Find the minimal data type of a scalar value in Python

AmitDiwan

AmitDiwan

Updated on 28-Feb-2022 06:14:59

209 Views

The numpy.min_scalar() method finds the minimal data type. The 1st parameter is the value whose minimal data type is to be found. For scalar, returns the data type with the smallest size and smallest scalar kind which can hold its value. For non-scalar array, returns the vector’s dtype unmodified. Floating ... Read More

Return the cumulative sum of array elements treating NaNs as zero in Python

AmitDiwan

AmitDiwan

Updated on 28-Feb-2022 06:00:39

209 Views

To return the cumulative sum of array elements over a given axis treating NaNs as zero, use the nancumprod() method. The cumulative sum does not change when NaNs are encountered and leading NaNs are replaced by zeros. Zeros are returned for slices that are all-NaN or empty.The method returns a ... Read More

Compute the Hyperbolic cosine of the array elements in Python

AmitDiwan

AmitDiwan

Updated on 28-Feb-2022 05:56:54

104 Views

To compute the Hyperbolic cosine of the array elements, use the numpy.cosine() method in Python Numpy. The method is equivalent to 1/2 * (np.exp(x) + np.exp(-x)) and np.cos(1j*x). Returns the corresponding hyperbolic cosine values. This is a scalar if x is a scalar. The 1st parameter, x is input array. ... Read More

Get the Machine limits information for float with instances in Python

AmitDiwan

AmitDiwan

Updated on 28-Feb-2022 05:39:40

107 Views

To get the machine limits information for float types, use the numpy.finfo() method in Python Numpy. The first parameter is the float i.e. the kind of float data type to get information about.StepsAt first, import the required library −import numpy as npThe min is the minimum value of given dtype ... Read More

Java Program to Print Half Diamond Star Pattern

AmitDiwan

AmitDiwan

Updated on 28-Feb-2022 05:38:26

892 Views

In this article, we will understand how to print half diamond star pattern. The pattern is formed by using multiple for-loops and print statements.Below is a demonstration of the same −InputSuppose our input is −Enter the number of rows : 8OutputThe desired output would be −The half diamond pattern : ... Read More

Return an array with the number of nonoverlapping occurrences of substring in Python

AmitDiwan

AmitDiwan

Updated on 28-Feb-2022 05:36:55

134 Views

To return an array with the number of non-overlapping occurrences of substring, use the numpy.char.count() method in Python Numpy. The first parameter is the sub i.e. the substring to search for. The numpy.char module provides a set of vectorized string operations for arrays of type numpy.str_StepsAt first, import the required ... Read More

Round to nearest integer towards zero in Python

AmitDiwan

AmitDiwan

Updated on 28-Feb-2022 05:33:38

1K+ Views

To round to nearest integer towards zero, use the numpy.fix() method in Python Numpy. It rounds an array of floats element-wise to nearest integer towards zero. The rounded values are returned as floats. The 1st parameter, x is an array of floats to be rounded. The 2nd parameter, out is ... Read More

Java Program to Print Hollow Right Triangle Star Pattern

AmitDiwan

AmitDiwan

Updated on 25-Feb-2022 13:33:52

4K+ Views

In this article, we will understand how to print hollow right triangle star pattern. The pattern is formed by using multiple for-loops and print statements. For the pyramid at the first line it will print one star, and at the last line it will print n number of stars. For ... Read More

Java Program to Print Inverted Star Pattern

AmitDiwan

AmitDiwan

Updated on 25-Feb-2022 13:09:48

1K+ Views

In this article, we will understand how to print inverted star pattern. The pattern is formed by using multiple for-loops and print statements.Below is a demonstration of the same −InputSuppose our input is −Enter the size : 8OutputThe desired output would be −The inverted star pattern *************** ************* ... Read More

Advertisements