AttributeError: 'numpy.ndarray'オブジェクトに属性がありません '挿入'
コード:
numpyをnpとしてインポート
np.set_printoptions(threshold = 1e6)
test = np.load( 'E:/ jiaxin / some rotten mess / 034_pbb.npy')
test = test [0]
印刷(テスト)
test1 = test [0]
print(test1)
print(test [1:])
print(test [1:] / 4)
test2 = test [1:] / 4
test2.insert(0、test1)
print(test2)
コードの実行中にエラーが発生しました:
トレースバック(最後の最後の呼び出し):
[-2.72441649 29.71287845 162.18161245 193.31958149 23.76840839]
<module>内のファイル「E:/ jiaxin / somerotten mess / reducer / 2.py」、278行目
test2.insert(0、test1)
-2.72441649437
AttributeError: 'numpy.ndarray'オブジェクトに属性がありません '挿入'
[29.71287845 162.18161245 193.31958149 23.76840839]
[7.42821961 40.54540311 48.32989537 5.9421021]
実行結果から、リスト配列と.ndarrayの表示も異なることがわかります。解決:
numpyをnpとしてインポート
np.set_printoptions(threshold = 1e6)
test = np.load( 'E:/ jiaxin / some rotten mess / 034_pbb.npy')
test = test [0]
印刷(テスト)
test1 = test [0]
print(test1)
print(test [1:])
print(test [1:] / 4)
test2 = test [1:] / 4
test2 = np.insert(test2、0、test1)
print(test2)
それは成功です:変更されたコード:test2.insert(0、test1)がtest2 = np.insert(test2、0、test1)に変更されました
(実験結果)
[-2.72441649 29.71287845 162.18161245 193.31958149 23.76840839]
-2.72441649437
[29.71287845 162.18161245 193.31958149 23.76840839]
[7.42821961 40.54540311 48.32989537 5.9421021]
[-2.72441649 7.42821961 40.54540311 48.32989537 5.9421021]