Python:数组添加数据和删除数据

# 行添加,删除数据
valid_tmp = np.append(valid_tmp, train_tmp[idx],axis=0)  # train_tmp[idx]和valid_tmp维数相同
train_tmp = np.delete(train_tmp, idx, axis=0)  # 删除train_tmp[idx, :]的数据,idx可以是个list
# 列添加删除数据
valid_tmp = np.append(valid_tmp, train_tmp[:, idx],axis=1)  # train_tmp[idx]和valid_tmp维数相同
train_tmp = np.delete(train_tmp, idx, axis=1)  # 删除train_tmp[:, idx]的数据,idx可以是个list

你可能感兴趣的:(Python,python)