【发布时间】:2021-09-20 14:00:13
【问题描述】:
我正在尝试使用以下内容进行 t 检验。它最初有效。但是,现在,它显示以下错误,
'numpy.float64' 对象没有属性 'ttest_ind'
col=list(somecolumns)
for i in col:
x = np.array(data1[data1.LoanOnCard == 0][i])
y = np.array(data1[data1.LoanOnCard == 1][i])
t, p_value = stats.ttest_ind(x,y, axis = 0,equal_var=False)
if p_value < 0.05: # Setting our significance level at 5%
print('Rejecting Null Hypothesis. Loan holders and non-Loan holders are not same for',i,'P value is %.2f' %p_value)
else:
print('Fail to Reject Null Hypothesis. Loan holders and non-Loan holders are same for',i,'P value is %.2f' %p_value)
我正在努力寻找答案。无法解决。
【问题讨论】:
-
不清楚这段代码中
stats是什么。你说它以前有效,你有没有机会创建一个名为stats的变量?
标签: pandas numpy data-science scipy.stats