본문 바로가기
언어/ㄴPython

[python] what is difference between numpy's 'array' and 'asarray'

by 공대우냉이 2016. 1. 19.
numpy.array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0)

vs

numpy.asarray(a, dtype=None, order=None)

it is like array, except it has fewer options, specially copy=False. but array is copy=True

The following arguments are those that may be passed to array and not asarray as mentioned in the documentation :

copy : bool, optional If true (default), then the object is copied. Otherwise, a copy will only be made if __array__ returns a copy, if obj is a nested sequence, or if a copy is needed to satisfy any of the other requirements (dtype, order, etc.).

subok : bool, optional If True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array (default).

ndmin : int, optional Specifies the minimum number of dimensions that the resulting arrayshould have. Ones will be pre-pended to the shape as needed to meet this requirement.

 

===============================================================================================================================================================

Reference

http://stackoverflow.com/questions/14415741/numpy-array-vs-asarray

'언어 > ㄴPython' 카테고리의 다른 글

[python] generating random array  (0) 2016.01.21
[python] what is assert  (0) 2016.01.21
[python] basic python  (0) 2016.01.19
[python] 'from X import name' vs 'import X.name'  (0) 2016.01.17
[python] understanding for 'from, import'  (0) 2016.01.17