The asscaler()
function in Python is used to return a scalar equivalent of a size 1 array.
The asscalar()
function has been deprecated since the introduction of version 1.16 of NumPy and the numpy.ndarray.item()
function has become the alternate function to it. Preceding versions of the NumPy 1.16 version support the ascalar()
function, while succeeding versions of it do not.
numpy.asscalar(a)
The asscaler()
function takes a single parameter value, a
, which represents the input array of size 1.
The asscaler()
function returns a scalar representation of the input array arr1
.
import numpy as np# creating an input arrray of size 1arr1 = np.array([25])# converting to scalarprint(np.asscalar(arr1))
numpy
module.1
named arr1
.arr1
, using the asscalar()
function.