[PYTHON] About Numpy array and asarray

While learning Python 1st grade, the notation numpy.asarray came out, so I checked it. When I looked it up, numpy.array came out, so I will explain the difference.

np.array (list)

import numpy as np
print(np.array([1, 2, 3]))

>>>Output result
>>>[1 2 3]

continue

np.asarray (list)

import numpy as np
print(np.asarray([1, 2, 3]))

>>>Output result
>>>[1 2 3]

So what's the difference?

Here is different

np.array

copy_array[0] = 100
print(x)
print(copy_array)

>>>[1 2 3]
>>>[100 2 3]

np.asarray

copy_asarray[0] = 100
print(x)
print(copy_asarray)

>>>[100 2 3]
>>>[100 2 3]

In conclusion, asarray inherits the one before copying.

Recommended Posts

About Numpy array and asarray
About numpy
About _ and __
NumPy array manipulation (3)
list and numpy
NumPy array manipulation (1)
Differences between Numpy 1D array [x] and 2D array [x, 1]
About Numpy broadcast
About cumulative assignment of lists and numpy arrays
Python and numpy tips
About all of numpy
About cross-validation and F-number
About import error of numpy and scipy in anaconda
This and that about pd.DataFrame
Linux (about files and directories)
About python objects and classes
About Python variables and objects
About LINUX files and processes
About Raid group and LUN
About fork () function and execve () function
About Django's deconstruct and deconstructible
About Python, len () and randint ()
About Python datetime and timezone
About Sharpe Ratio and Sortino Ratio
Create a python numpy array
NumPy and matplotlib environment construction
Extract array elements and indexes in descending order with numpy
About Python and regular expressions
Multidimensional array calculation without Numpy
About http.Handle () and http.NewServeMux (). Handle ()
Python # About reference and copy
About Python sort () and reverse ()
About the bug that anaconda fails to import numpy and scipy
About installing Pwntools and Python2 series
Subscript access to python numpy array
Summary and common errors about cron
About python dict and sorted functions
About dtypes in Python and Cython
About MkDocs themes and their customs
About Python pickle (cPickle) and marshal
Difference between Numpy randint and Random randint
[Python] About Executor and Future classes
About Python, from and import, as
Multidimensional array calculation without Numpy Part 2
Python application: Numpy Part 3: Double array
Compare Python and JavaScript array loops
Extract multiple elements with Numpy array
Invert numpy Boolean array in tilde