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.
import numpy as np
print(np.array([1, 2, 3]))
>>>Output result
>>>[1 2 3]
continue
import numpy as np
print(np.asarray([1, 2, 3]))
>>>Output result
>>>[1 2 3]
So what's the difference?
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