我正在使用t-test处理一个熊猫数据帧。我有大约40个属性和一个目标变量。
我正在使用这段代码进行t-test分析:
stats.ttest_ind(df[df['target']==1]['variable'], df[df['target']==0]['variable'])我也导入了必要的模块:
from scipy import stats然而,我一直收到这个错误,并且不确定我做错了什么:
AttributeError Traceback (most recent call last)
<ipython-input-187-dbb554ef9ddf> in <module>()
----> 1 stats.ttest_ind(df[df['target']==1]['variable'],
df[df['target']==0]['variable'])
AttributeError: 'function' object has no attribute 'ttest_ind'有没有人能建议一些解决方案,我已经在这个问题上工作了几个小时,但不知道哪里出了问题。
发布于 2021-03-17 12:51:54
试一试
from scipy.stats import ttest_ind
ttest_ind(df[df['target']==1]['variable'], df[df['target']==0]['variable'])在你的代码中有没有一个叫做stats的函数?
def stats(x):
print(x)
stats.ttest_ind()AttributeError:“function”对象没有特性“”ttest_ind“”
https://stackoverflow.com/questions/66667065
复制相似问题