簡體   English   中英

t 測試模塊問題 python

[英]t-test module issue python

我正在對 pandas dataframe 進行 t 檢驗。 我有大約 40 個屬性和一個目標變量。

我正在使用這段代碼進行 t 檢驗分析:

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'

任何人都可以為此提出一些解決方案,我已經在這個問題上工作了幾個小時,不知道出了什么問題。

嘗試

from scipy.stats import ttest_ind

ttest_ind(df[df['target']==1]['variable'], df[df['target']==0]['variable'])

您的代碼中是否有一個名為 stats 的 function ?

def stats(x):
    print(x)

stats.ttest_ind()

AttributeError: 'function' object 沒有屬性 'ttest_ind'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM