我一直在使用scipy的binned_statistic_2d函数来绘制一些数据的2d直方图,特别是通过设置expand_binnumbers=True来返回数据所在bin的索引列表。直到今天,它一直工作得很好。以下代码演示了我的问题:
import numpy as np
from scipy.stats import binned_statistic_2d as hist
# my data is two arrays of numbers
x = np.random.random((5,))
y = np.random.random((5,))
# I need to know which bin the values are in so I return the bin_idx
data = hist(x,y, bins = [2,2], statistic = 'count', values = None, expand_binnumbers = True)
bin_idx = data[3]
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
你知道为什么这会突然停止工作吗
Scipy的最新更新在某种程度上打破了这一局面——正如@WarrenWeckesser在评论中所说的,设置values=x可以让事情再次正常工作
相关问题 更多 >
编程相关推荐