我试图在for循环中运行某些东西,并分析bin向量不变的某些数据的2D直方图。他们必须固定。到目前为止我已经
了import numpy as np
nbins = 300
XgBins=np.linspace(3.21,3.31, nbins)
volBins=np.linspace(0,0.00032,nbins)
for k in range(0,121):
data = np.genfromtxt('/home/file'+str(k)+'.csv',delimiter=',', dtype = float)
Xg = [row[8] for row in data]
vol = [row[14] for row in data]
Hbg, xedgesbg, yedgesbg = np.histogram2d(Xg[1:len(Xg)],vol[1:len(vol)], range = [XgBins, volBins])
但是,我得到了
ValueError: too many values to unpack
错误。我不太确定它是在做我想做的事情。我在这里缺少什么?
答案 0 :(得分:2)
docs表示如果您想明确提供分档,则应为其提供bins
关键字参数,即
H, x, y = np.histogram2d(Xg[1:len(Xg)],vol[1:len(vol)], bins=[XgBins, volBins])