numpy.asscalar()
is used when we want to convert an array of size 1 to its scalar equivalent.
Syntax : numpy.asscalar (arr)
Parameters:
arr: [ndarray] Input array of size 1.Return: Scalar representation of arr. The output data type is the same type returned by the input’s item method.
Code # 1: Work
|
Output:
Input array: [8] output scalar from input array: 8
Code # 2:
|
Output:
Input ar ray from list: [2] output scalar from input list: 2