嗨,我正在尝试使用以下方法将一些数据分箱到频率箱中:
import scipy as sc
sc.stats.binned_statistic([0, 1, 0, 0 ,1], py.arange(1),
statistic="count", bins=2, range=(0, 2.0) )
这会产生一个错误(如下),没有range
参数就不会发生。此功能的文档建议range=(float, float)
应该可以解决问题。
谁能告诉我我在这里缺少什么?
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-136-1cf57b135132> in <module>()
1
----> 2 sc.stats.binned_statistic([0, 1, 0, 0 ,1], py.arange(1), statistic="count", bins=2, range=(0,2))
/usr/lib/python2.7/dist-packages/scipy/stats/_binned_statistic.pyc in binned_statistic(x, values, statistic, bins, range)
90
91 medians, edges, xy = binned_statistic_dd([x], values, statistic,
---> 92 bins, range)
93
94 return medians, edges[0], xy
/usr/lib/python2.7/dist-packages/scipy/stats/_binned_statistic.pyc in binned_statistic_dd(sample, values, statistic, bins, range)
281 smax = np.zeros(D)
282 for i in np.arange(D):
--> 283 smin[i], smax[i] = range[i]
284
285 # Make sure the bins have a finite width.
TypeError: 'int' object is not iterable