File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/extensions/TeX/AmsMath.js

2011年12月5日月曜日

python 3次元配列の作り方




1番目の方法
>>> a = [[] for i in xrange(5)]
>>> b = [a for i in xrange(90)]
>>> c = [b for i in xrange(981)]
>>> d = numpy.array(c)
>>> d
array([], shape=(981, 90, 5, 0), dtype=float64)
>>>d.shape
(981,90,5,0)

2番目の方法
a = numpy.zeros([981,90,5])
a.shape
(981, 90,5)

a[0][0] = ([1,2,3,4,5])




0 件のコメント :

コメントを投稿