numpy.asarray() in Python

The numpy.asarray()function is used to convert the input to an array. Input includes lists, lists of tuples, tuples, tuples of tuples,etc,.



arr : This parameter includes theinput data, in any form that can be converted to an array. This includes lists, tuples, lists of tuples,tuples of tuples, tuples of listsetc,.
dtype : It is an optional parameter. It depicts the data type of returned array, and by default, it is a float.
order : This parameter states whether to use row-major (C-style) or column-major (Fortran-style) memory representation. By defaults it takes ‘C-style’.


This function returns the array interpretation of arr. If the parameter ‘arr’ is a subclass, a base class is returned.

Example 1


Input  list :

output array from input list :

Example 2


Input  touple :

output array from input touple :

Pin It on Pinterest

Share This