我正在尝试在每次迭代期间将值插入到空数组中,现在我已在代码中将值插入索引,但会覆盖所有先前的值,我不确定该怎么做,
#Empty array is created here
complete = np.empty((128, 86), dtype = float)
#From the result dictionary elements are appended here
feature_1 = np.array([])
feature_2 = np.array([])
try:
for key, value in six.iteritems(result_1):
if key.startswith("original_"):
feature_1 = np.append( feature_1, result_1[key])
feature_2 = np.append( feature_2, result_2[key])
#And here i try to insert the feature_1 array to this array
complete[index, :] = feature_1
任何建议都会很有帮助。 让我知道是否需要更多说明,代码等 预先感谢。
示例
在迭代1期间,数组complete
具有除索引first
之外的所有随机值,由于此操作complete[index, :] = feature_1
,现在在第二次操作期间,first
索引值变为随机值,但是second
元素具有特征值,并且对所有值重复此操作,最后所有值将具有随机值,除了last
索引
已修复。错误是我在每次迭代过程中都在重新初始化空数组,谢谢您的帮助。