在NumPy中保存文本文件时出错

时间:2015-04-30 16:14:42

标签: python numpy

这是为了将数组保存在磁盘中。

entireFileText.equals(Email)  

错误是:

function onOpen() {
  var ss = SpreadsheetApp.getActive();
  var sheets = ss.getSheets(); // array of all sheet objects in ss
  var numSheets = ss.getNumSheets(); // count of sheets

//show all the rows
  sheet.showRows(1, maxRows);

//get data from clumn C
  var data = sheet.getRange('C:C').getValues();

//iterate over all rows
  for(var i=0; i< data.length; i++){
//compare column, if no, then hide row
    if(data[i][0] == 'no'){
      sheet.hideRows(i+1);
  }
 }
}

如何解决? outfile如下所示:

 import numpy as np, itertools

x1 = np.linspace(0.1, 3.5, 3)
x2 = np.arange(5, 24, 3)
x3 = np.arange(50.9, 91.5, 3)

def calculate(x1,x2,x3):
    res = x1**5+x2*x1+x3
    return res

products = np.array(list(itertools.product(x1,x2,x3)))

results = np.array([calculate(a,b,c) for a,b,c in products])
print results

np.savetxt('test.out', (products,results)) 

1 个答案:

答案 0 :(得分:2)

您必须以兼容的方式将两个阵列粘合在一起。最简单的方法可能是

arr_combined = np.column_stack((products,results))

np.savetxt('test.out',arr_combined)

np.column_stack将一维数组作为列向量添加到二维数组中。