Convert list to numpy.ndarray
524 ワード
l_2d = [[0, 1, 2], [3, 4, 5]]
arr_2d = np.array(l_2d)
print(arr_2d)
# [[0 1 2]
# [3 4 5]]
source: numpy_ndarray_list.pyMulti-dimensional list are just nested lists (list of lists), so it doesn't matter if the number of elements in the list doesn't match.
However, passing it to numpy.array() creates numpy.ndarray whose elements are built-in list.
単純なリストが1つしかない場合はnp.endarray()を使用して、リストをendarrayに簡単に変換できます.ただし、単一のリストではなくネストされたリストであればnp.endarrayに変換するにはarray()を使用します.
Reference
この問題について(Convert list to numpy.ndarray), 我々は、より多くの情報をここで見つけました https://velog.io/@flawednworthy/Convert-list-to-numpy.ndarrayテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol