Javatpoint Logo
Javatpoint Logo

numpy.asarray()

This function is used to create an array by using the existing data in the form of lists, or tuples. This function is useful in the scenario where we need to convert a python sequence into the numpy array object.

Syntax

Parameters

It accepts the following parameters.

  1. shape: It is the Tuple defining the shape of the matrix.
  2. dtype: It is the data type each item of the array
  3. order: It is the insertion order of the array. The default is C.

Return

An array with the equivalent values to the sequence is returned.

Example

Output:


[1 2 3 4 5 6 7]

Example: Creating a numpy array from the Tuple

Output:


[1 2 3 4 5 6 7]

Example: creating a numpy array using more than one list

Output:


[list([1, 2, 3, 4, 5, 6, 7]) list([8, 9])]

Next Topicnumpy.frombuffer()





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA