我想要将一些柱状图数据保存在CSV文件中。这是我写的代码:
对于每个箱子,我想保存箱子的值和相应的计数
使用当前代码会出现错误
完整的回溯信息如下:
ExportName_csv = 'ExportData/' + FileName + '.csv'
freq, bins = np.histogram(ValList,bins)
np.savetxt(ExportName_csv, izip(freq, bins), delimiter="\t")
对于每个箱子,我想保存箱子的值和相应的计数
freq
到 ExportName_csv
中。我希望不同箱子的值在不同行中;在每一行中,值用逗号分隔。使用当前代码会出现错误
IndexError: tuple index out of range
。您建议怎么做?完整的回溯信息如下:
np.savetxt(ExportName_csv, izip(freq, bins), delimiter="\t")
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/npyio.py", line 976, in savetxt ncol = X.shape[1]
IndexError: tuple index out of range
np.savetxt(ExportName_csv, izip(freq, bins), delimiter="\t") File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/npyio.py", line 976, in savetxt ncol = X.shape[1] IndexError: tuple index out of range
- albus_cjson.dump(ValList, f)
打印的ValList
值的示例:http://cl.ly/text/2n420p2o2Y3S - albus_c