
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10476 Articles for Python

203 Views
To compute the Hyperbolic tangent of the array elements, use the numpy.tanh() method in Python Numpy. The method is equivalent to np.sinh(x)/np.cosh(x) or -1j * np.tan(1j*x). Returns the corresponding hyperbolic tangent values. This is a scalar if x is a scalar. The 1st parameter, x is input array. The 2nd and 3rd parameters are optional.The 2nd parameter is an ndarray, A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned.The 3rd parameter is the condition is broadcast over the input. ... Read More

490 Views
To compute the Hyperbolic tangent, use the numpy.tanh() method in Python Numpy. Equivalent to np.sinh(x)/np.cosh(x) or -1j * np.tan(1j*x). Returns the corresponding hyperbolic tangent values. This is a scalar if x is a scalar. The 1st parameter, x is input array. The 2nd and 3rd parameters are optional.The 2nd parameter is an ndarray, A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned.The 3rd parameter is the condition is broadcast over the input. At locations where the condition is True, ... Read More

674 Views
To get the machine limits information for float types, use the numpy.finfo() method in Python Numpy. The first parameter is the floating type 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 and max is the minimum value of given dtype.Checking for float16 type −a = np.finfo(np.float16) print("Minimum of float16 type...", a.min) print("Maximum of float16 type...", a.max)Checking for float32 type −b = np.finfo(np.float32) print("Minimum of float32 type...", b.min) print("Maximum of float32 type...", b.max)Checking for float64 type −c = np.finfo(np.float64) print("Minimum of ... Read More

185 Views
To get the machine limits information for integer types, use the numpy.iinfo() method in Python Numpy. The first parameter is the int_type i.e. the kind of integer data type to get information about.StepsAt first, import the required library −import numpy as npThe min is the minimum value of given dtype and max is the minimum value of given dtype.Checking for int16 type with instances −a = np.iinfo(np.int16(20)) print("Minimum of int16 type...", a.min) print("Maximum of int16 type...", a.max)Checking for int32 type with instances −b = np.iinfo(np.int32(30)) print("Minimum of int32 type...", b.min) print("Maximum of int32 type...", b.max)Checking for int64 type with instances ... Read More

288 Views
To get the machine limits information for integer types, use the numpy.iinfo() method in Python Numpy. The first parameter is the int_type i.e. the kind of integer data type to get information about.StepsAt first, import the required library −import numpy as npThe min is the minimum value of given dtype and max is the minimum value of given dtype.Checking for int16 type −a = np.iinfo(np.int16) print("Minimum of int16 type...", a.min) print("Maximum of int16 type...", a.max)Checking for int32 type −b = np.iinfo(np.int32) print("Minimum of int32 type...", b.min) print("Maximum of int32 type...", b.max)Checking for int64 type −c = np.iinfo(np.int64) print("Minimum of int64 ... Read More

454 Views
To return a scalar type which is common to the input arrays, use the numpy.common_type() method in Python Numpy. The 1st parameter is the input array(s). The return type will always be an inexact (i.e. floating point) scalar type, even if all the arrays are integer arrays. If one of the inputs is an integer array, the minimum precision type that is returned is a 64-bit floating point dtype.All input arrays except int64 and uint64 can be safely cast to the returned dtype without loss of information.StepsAt first, import the required library −import numpy as npTo return a scalar type ... Read More

167 Views
The numpy.can_cast() method returns True if array scalar and data type can occur according to the casting rule. The 1st parameter is the scalar or data type or array to cast from. The 2nd parameter is the data type to cast to.StepsAt first, import the required library −import numpy as npChecking if array scalar and data type can occur according to the casting rule −print("Checking with can_cast() method in Numpy") print("Result...", np.can_cast(np.array(20), 'i1')) print("Result...", np.can_cast(np.array(280), 'i1')) print("Result...", np.can_cast(np.array(80), 'u1')) print("Result...", np.can_cast(np.array(300.7), np.float32)) print("Result...", np.can_cast(np.array(120.6), np.float64)) print("Result...", np.can_cast(np.array(7.2e100), np.float32)) print("Result...", np.can_cast(np.array(6.5e100), np.float64))Exampleimport numpy as np # The numpy.can_cast() method returns ... Read More

183 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 second parameter is the "timezone", the Timezone information to use when displaying the datetime. If ‘UTC’, end with a Z to indicate UTC time. If ‘local’, convert to the local timezone first, and suffix with a +-#### timezone offset. If a tzinfo object, then do as with ‘local’, but use the specified timezone.StepsAt first, import the required ... Read More

318 Views
To return the base 2 logarithm of the input array, use the numpy.log2() method in Python Numpy The method returns Base-2 logarithm of x. This is a scalar if x is a scalar. The 1st parameter, x is the input value, array-like. The 2nd parameter is out, a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.The 3rd parameter is where, the ... Read More

196 Views
To determine common type following standard coercion rules, use the numpy.find_common_type() method in Python numpy. The 1st argument is a list of dtypes or dtype convertible objects representing arrays. The 2nd argument is A list of dtypes or dtype convertible objects representing scalars.The find_common_type() method returns the common data type, which is the maximum of array_types ignoring scalar_types, unless the maximum of scalar_types is of a different kind (dtype.kind). If the kind is not understood, then None is returned.StepsAt first, import the required library −import numpy as npUsing the find_common_type() method in Numpy. Determine common type following standard coercion rules ... Read More