因爲(我認爲)升級到python 3.5(從2.7),我得到了一個奇怪的錯誤他們改變了python 3中的astype('string')嗎?
當試圖打開一個文件(充滿位串)和他們操縱這樣的字符串:
#bit string data
data = open(read_path+'genomes'+str(time)).read().replace(',','\n').replace('\n','')
x = data.split()
CA = np.array(x).astype('string')
Genomes = np.reshape(CA, (size,size))
genomelength = len(Genomes[0][0])
for entry in range(0, size**2): total_mut1[entry] = np.array(sum_digits(CA[entry])).astype('int')
mut_array1 = np.reshape(total_mut1, (size,size))
升級之前,這工作...
現在我得到這個錯誤:
CA = np.array(x).astype('string')
TypeError: data type "string" not understood
這只是一個愚蠢的修復 (我希望)。提前致謝。
什麼用astype發生(STR) ? – pvg
解決了它,謝謝@pvg – cancerconnector