🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.asarray.html
numpy.asarray — NumPy v2.2 Manual
numpy.asarray(a, dtype=None, order=None, *, device=None, copy=None, like=None)# Convert the input to an array. Parameters: aarray_like · Input data, in any form that can be converted to an array. This includes lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays.
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-asarray-in-python
numpy.asarray() in Python - GeeksforGeeks
November 12, 2021 - # Python program explaining # numpy.asarray() function import numpy as geek my_tuple = ([1, 3, 9], [8, 2, 6]) print ("Input tuple : ", my_tuple) out_arr = geek.asarray(my_tuple) print ("output array from input tuple : ", out_arr)
People also ask

Does np.asarray() copy an array?
Not always. A compatible ndarray may be returned or shared, while dtype or order requirements can require conversion.
🌐
pythonpool.com
pythonpool.com › home › numpy › numpy asarray(): convert data without unnecessary copies
Why is Numpy asarray() Important in Python?
What does np.asarray() do?
np.asarray() converts array-like input into an ndarray and can avoid an unnecessary copy when the input is already compatible.
🌐
pythonpool.com
pythonpool.com › home › numpy › numpy asarray(): convert data without unnecessary copies
Why is Numpy asarray() Important in Python?
What is the difference between np.asarray() and np.array()?
asarray() prefers avoiding copies, while np.array() is commonly used when independent storage and explicit copy behavior are needed.
🌐
pythonpool.com
pythonpool.com › home › numpy › numpy asarray(): convert data without unnecessary copies
Why is Numpy asarray() Important in Python?
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.asarray.html
numpy.asarray — NumPy v2.5 Manual
numpy.asarray(a, dtype=None, order=None, *, device=None, copy=None, like=None)# Convert the input to an array. Parameters: aarray_like · Input data, in any form that can be converted to an array. This includes lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays.
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.asarray.html
numpy.asarray — NumPy v2.6.dev0 Manual
numpy.asarray(a, dtype=None, order=None, *, device=None, copy=None, like=None)# Convert the input to an array. Parameters: aarray_like · Input data, in any form that can be converted to an array. This includes lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays.
🌐
Programiz
programiz.com › python-programming › numpy › methods › asarray
NumPy asarray()
The array() method creates a copy of an existing object whereas asarray() creates a new object only when needed.
🌐
TutorialsPoint
tutorialspoint.com › numpy › numpy_asarray_function.htm
Numpy asarray() Function
The Numpy asarray() function is used to convert the given input to an array. The input data can be in the form of list, tuple, scalar, string or set. The data-tye of the array is inferred from the input data.
🌐
Vultr Docs
docs.vultr.com › python › third party › numpy › asarray()
Python Numpy asarray() - Convert to Array
November 8, 2024 - The numpy.asarray() function in Python is an integral part of the Numpy library, used extensively for converting various input data types like lists, tuples, and other array-like objects into a Numpy ndarray.
🌐
Interactive Chaos
interactivechaos.com › en › python › function › numpyasarray
numpy.asarray | Interactive Chaos
January 22, 2021 - Python scenarios · Full name · numpy.asarray · Library · NumPy · Syntax · numpy.asarray(a, dtype = None, order = None) Description · The numpy.asarray function converts a data structure to a NumPy array.
Find elsewhere
🌐
w3resource
w3resource.com › numpy › manipulation › asarray.php
NumPy: numpy.asarray() function - w3resource
March 24, 2023 - The numpy.asarray() function is used to convert n given input to an array.
🌐
Python Pool
pythonpool.com › home › numpy › numpy asarray(): convert data without unnecessary copies
Why is Numpy asarray() Important in Python?
July 13, 2026 - NumPy asarray() converts array-like input into an ndarray while avoiding an unnecessary copy when the input is already compatible. It accepts lists, tuples, scalars, and existing arrays.
Top answer
1 of 8
335

The definition of asarray is:

def asarray(a, dtype=None, order=None):
    return array(a, dtype, copy=False, order=order)

So it is like array, except it has fewer options, and copy=False. array has copy=True by default.

The main difference is that array (by default) will make a copy of the object, while asarray will not unless necessary.

2 of 8
240

Since other questions are being redirected to this one which ask about asanyarray or other array creation routines, it's probably worth having a brief summary of what each of them does.

The differences are mainly about when to return the input unchanged, as opposed to making a new array as a copy.

array offers a wide variety of options (most of the other functions are thin wrappers around it), including flags to determine when to copy. A full explanation would take just as long as the docs (see Array Creation, but briefly, here are some examples:

Assume a is an ndarray, and m is a matrix, and they both have a dtype of float32:

  • np.array(a) and np.array(m) will copy both, because that's the default behavior.
  • np.array(a, copy=False) and np.array(m, copy=False) will copy m but not a, because m is not an ndarray.
  • np.array(a, copy=False, subok=True) and np.array(m, copy=False, subok=True) will copy neither, because m is a matrix, which is a subclass of ndarray.
  • np.array(a, dtype=int, copy=False, subok=True) will copy both, because the dtype is not compatible.

Most of the other functions are thin wrappers around array that control when copying happens:

  • asarray: The input will be returned uncopied iff it's a compatible ndarray (copy=False).
  • asanyarray: The input will be returned uncopied iff it's a compatible ndarray or subclass like matrix (copy=False, subok=True).
  • ascontiguousarray: The input will be returned uncopied iff it's a compatible ndarray in contiguous C order (copy=False, order='C').
  • asfortranarray: The input will be returned uncopied iff it's a compatible ndarray in contiguous Fortran order (copy=False, order='F').
  • require: The input will be returned uncopied iff it's compatible with the specified requirements string.
  • copy: The input is always copied.
  • fromiter: The input is treated as an iterable (so, e.g., you can construct an array from an iterator's elements, instead of an object array with the iterator); always copied.

There are also convenience functions, like asarray_chkfinite (same copying rules as asarray, but raises ValueError if there are any nan or inf values), and constructors for subclasses like matrix or for special cases like record arrays, and of course the actual ndarray constructor (which lets you create an array directly out of strides over a buffer).

🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.asarray.html
numpy.asarray — NumPy v2.1 Manual
numpy.asarray(a, dtype=None, order=None, *, device=None, copy=None, like=None)# Convert the input to an array. Parameters: aarray_like · Input data, in any form that can be converted to an array. This includes lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays.
🌐
NumPy
numpy.org › doc › 1.25 › reference › generated › numpy.asarray.html
numpy.asarray — NumPy v1.25 Manual
numpy.asarray(a, dtype=None, order=None, *, like=None)# Convert the input to an array. Parameters: aarray_like · Input data, in any form that can be converted to an array. This includes lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays.
🌐
GeeksforGeeks
geeksforgeeks.org › numpy › difference-between-np-asarray-and-np-array
Difference between np.asarray() and np.array()? - GeeksforGeeks
July 23, 2025 - List in python : [5, 6, 7, 9] Numpy Array in python : [5 6 7 9] <class 'numpy.ndarray'> The numpy.asarray()function is used when we want to convert the input to an array. Input can be lists, lists of tuples, tuples, tuples of tuples, tuples ...
🌐
Javatpoint
javatpoint.com › numpy-asarray
numpy.asarray() in Python - Javatpoint
in Python The numpy module of Python provides a function called . This function is used to create an array without initializing the entries of given shape and type.
🌐
Data-apis
data-apis.org › array-api › 2024.12 › API_specification › generated › array_api.asarray.html
asarray — Python array API standard 2024.12 documentation
asarray(obj: array | bool | int | float | complex | NestedSequence | SupportsBufferProtocol, /, *, dtype: dtype | None = None, device: device | None = None, copy: bool | None = None) → array¶ · Convert the input to an array. ... obj (Union[array, bool, int, float, complex, NestedSequence[bool ...
🌐
Data-apis
data-apis.org › array-api › latest › API_specification › generated › array_api.asarray.html
asarray — Python array API standard 2025.12 documentation
asarray(obj: array | bool | int | float | complex | NestedSequence | SupportsBufferProtocol, /, *, dtype: dtype | None = None, device: device | None = None, copy: bool | None = None) → array¶ · Convert the input to an array. ... obj (Union[array, bool, int, float, complex, NestedSequence[bool ...
🌐
NumPy
numpy.org › doc › 1.26 › reference › generated › numpy.asarray.html
numpy.asarray — NumPy v1.26 Manual
numpy.asarray(a, dtype=None, order=None, *, like=None)# Convert the input to an array. Parameters: aarray_like · Input data, in any form that can be converted to an array. This includes lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays.
🌐
NumPy
numpy.org › doc › 2.4 › reference › generated › numpy.asarray.html
numpy.asarray — NumPy v2.4 Manual
numpy.asarray(a, dtype=None, order=None, *, device=None, copy=None, like=None)# Convert the input to an array. Parameters: aarray_like · Input data, in any form that can be converted to an array. This includes lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays.