为什么binned_statistic_2d现在抛出类型错误?

2024-09-30 18:26:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在使用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''

你知道为什么这会突然停止工作吗


Tags: theto数据importtruedatabinas