w3resource

NumPy Array manipulation: asscalar() function

numpy.asscalar() function

The asscalar() function is used to convert an array of size 1 to its scalar equivalent.

Syntax:

numpy.asscalar(a)
NumPy manipulation: asscalar() function

Version: 1.15.0

Parameter:

Name Description Required /
Optional
a Input array of size 1. Required

Return value:

out : scalar - Scalar representation of a. The output data type is the same type returned by the input’s item method.

Example: numpy.asscalar using a parameter

>>> import numpy as np
>>> np.asscalar(np.array([48]))
48

Pictorial Presentation:

NumPy manipulation: asscalar() function

Python - NumPy Code Editor:

Previous: asarray_chkfinite()
Next: require()