Writing to numpy array from dictionary

前端 未结 2 629
猫巷女王i
猫巷女王i 2021-01-14 07:32

I have a dictionary of file header values (time, number of frames, year, month, etc) that I would like to write into a numpy array. The code I have currently is as follows:

2条回答
  •  借酒劲吻你
    2021-01-14 07:48

    The problem seems to be that v is an int rather than a tuple. Try:

    arr=np.array([(k,v) for k,v in fileheader.iteritems()],dtype=["a3,a,i4,i4,i4,i4,f8,i4,i4,i4,i4,i4,i4,a10,a26,a33,a235,i4,i4,i4,i4,i4,i4"])
    

提交回复
热议问题