numpy.fromiter(iterable, dtype, count=-1)
Create a new 1-dimensional array from an iterable object.
Parameters: |
|
---|---|
Returns: |
|
Specify count
to improve performance. It allows fromiter
to pre-allocate the output array, instead of resizing it on demand.
>>> iterable = (x*x for x in range(5)) >>> np.fromiter(iterable, float) array([ 0., 1., 4., 9., 16.])
© 2005–2019 NumPy Developers
Licensed under the 3-clause BSD License.
https://docs.scipy.org/doc/numpy-1.17.0/reference/generated/numpy.fromiter.html