in
python
1import numpy as np 2a = np.array([1, 2, 3, 4, 5])
###聞きたいこと
2行目についてなのですが、numpyというライブラリーの中にあるarrayというクラスをインスタンス化したという認識で合っていますか?
気になる質問をクリップする
クリップした質問は、後からいつでもMYページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
回答2件
0
ベストアンサー
お疲れ様です。
雰囲気はそのとおりですが、
正確にはndarrayを返す関数だと思います。
ヘルプの一部を以下に抜粋します。
python
1>>> import numpy 2>>> help(numpy.array) 3Help on built-in function array in module numpy: 4 5array(...) 6 array(object, dtype=None, copy=True, order='K', subok=False, ndmin=0) 7 8 Create an array. 9 10 Parameters 11 ---------- 12 object : array_like 13 An array, any object exposing the array interface, an object whose 14 __array__ method returns an array, or any (nested) sequence. 15 dtype : data-type, optional 16 The desired data-type for the array. If not given, then the type will 17 be determined as the minimum type required to hold the objects in the 18 sequence. This argument can only be used to 'upcast' the array. For 19 downcasting, use the .astype(t) method. 20 copy : bool, optional 21 If true (default), then the object is copied. Otherwise, a copy will 22 only be made if __array__ returns a copy, if obj is a nested sequence, 23 or if a copy is needed to satisfy any of the other requirements 24 (`dtype`, `order`, etc.). 25 order : {'K', 'A', 'C', 'F'}, optional 26 Specify the memory layout of the array. If object is not an array, the 27 newly created array will be in C order (row major) unless 'F' is 28 specified, in which case it will be in Fortran order (column major). 29 If object is an array the following holds. 30 31 ===== ========= =================================================== 32 order no copy copy=True 33 ===== ========= =================================================== 34 'K' unchanged F & C order preserved, otherwise most similar order 35 'A' unchanged F order if input is F and not C, otherwise C order 36 'C' C order C order 37 'F' F order F order 38 ===== ========= =================================================== 39 40 When ``copy=False`` and a copy is made for other reasons, the result is 41 the same as if ``copy=True``, with some exceptions for `A`, see the 42 Notes section. The default order is 'K'. 43 subok : bool, optional 44 If True, then sub-classes will be passed-through, otherwise 45 the returned array will be forced to be a base-class array (default). 46 ndmin : int, optional 47 Specifies the minimum number of dimensions that the resulting 48 array should have. Ones will be pre-pended to the shape as 49 needed to meet this requirement. 50 51 Returns 52 ------- 53 out : ndarray 54 An array object satisfying the specified requirements. 55 56 See Also 57 -------- 58 empty_like : Return an empty array with shape and type of input. 59 ones_like : Return an array of ones with shape and type of input. 60 zeros_like : Return an array of zeros with shape and type of input. 61 full_like : Return a new array with shape of input filled with value. 62 empty : Return a new uninitialized array. 63 ones : Return a new array setting values to one. 64 zeros : Return a new array setting values to zero. 65 full : Return a new array of given shape filled with value. 66 67 68 Notes 69 ----- 70 When order is 'A' and `object` is an array in neither 'C' nor 'F' order, 71 and a copy is forced by a change in dtype, then the order of the result is 72 not necessarily 'C' as expected. This is likely a bug. 73 74 Examples 75 -------- 76 >>> np.array([1, 2, 3]) 77 array([1, 2, 3]) 78
投稿2019/08/11 01:45
総合スコア275
あなたの回答
tips
太字
斜体
打ち消し線
見出し
引用テキストの挿入
コードの挿入
リンクの挿入
リストの挿入
番号リストの挿入
表の挿入
水平線の挿入
プレビュー
質問の解決につながる回答をしましょう。 サンプルコードなど、より具体的な説明があると質問者の理解の助けになります。 また、読む側のことを考えた、分かりやすい文章を心がけましょう。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/11 02:48
2019/08/11 03:36
2019/08/11 05:17