numpy.fromiter()

This function is used to create a ndarray by using an iterable object. It returns a one-dimensional ndarray object.

Syntax

Parameters

It accepts the following parameters.

  1. Iterable: It represents an iterable object.
  2. dtype: It represents the data type of the resultant array items.
  3. count: It represents the number of items to read from the buffer in the array.

Return

An array created by using the iterable object is returned.

Example

Output:

[0. 2. 4. 6.]






Latest Courses