配列名が次のような複数の配列があります
Level1
Level2
Level3
.
.
など。各配列には4つの列と任意の数の行があります。列名は次の形式です
AP%i BP%i AS%i BS%i
ここ%i
で、は配列名の対応するインデックスに対応します(例Level1 -> AP01 BP01 AS01 BS01
)。列名が変数である正しい列名でそのような配列のdtypeを作成するにはどうすればよいですか?
次のようなものを使用して、必要な dtype を動的に生成できます。
for i in xrange(1, N+1): # N is number of arrays
arr = globals()['Level%i' % i] # this gets the Level<X> value for each i
arr.dtype = [('AP%02i' % i,float), ('BP%02i' % i, float), ('AS%02i' % i, float), ('BS%02i' % i, float)]
# example
print Level1[0]['AP01']
実際に持っているデータの種類に応じて、dtype の型を調整することを忘れないでください。