Ttest_indResult(statistic=nan, pvalue=nan) 错误
Ttest_indResult(statistic=nan, pvalue=nan) error
我在下面有以下命令:
Townames = []
Notowns = []
def run_ttest():
for key,value in enumerate(data['RegionName']):
if value in stateslist:
indexing = data['differ'].iloc[key]
Townames.append(indexing)
else:
indexing = data['differ'].iloc[key]
Notowns.append(indexing)
Unitowns = pd.DataFrame(columns = ['Unitownvalues'])
Notunitowns = pd.DataFrame(columns = ['Notunitownvalues'])
Unitowns['Unitownvalues'] = Townames
Notunitowns['Notunitownvalues'] = Notowns
Unitowns = Unitowns.dropna(subset=['Unitownvalues'])
Notunitowns = Notunitowns.dropna(subset=['Notunitownvalues'])
return
run_ttest()
from scipy import stats
stats.ttest_ind(Unitowns['Unitownvalues'],Notunitowns['Notunitownvalues'])
然而,我的输出是:
Ttest_indResult(statistic=nan, pvalue=nan)
我不明白这是为什么。
我删除了上面的 NAN 值:Unitowns['Unitownvalues']
和 Notunitowns['Notunitownvalues'].
有人能帮帮我吗?
确保添加最后一个参数(假设您正在比较的两个数据集的方差将相等 ):
stats.ttest_ind(Unitowns['Unitownvalues'],Notunitowns['Notunitownvalues'],equal_var=True)
而不是:
stats.ttest_ind(Unitowns['Unitownvalues'],Notunitowns['Notunitownvalues'])
这给了我一个输出:
Ttest_indResult(statistic=0.38697667088831, pvalue=0.69878181110717441)
我在下面有以下命令:
Townames = []
Notowns = []
def run_ttest():
for key,value in enumerate(data['RegionName']):
if value in stateslist:
indexing = data['differ'].iloc[key]
Townames.append(indexing)
else:
indexing = data['differ'].iloc[key]
Notowns.append(indexing)
Unitowns = pd.DataFrame(columns = ['Unitownvalues'])
Notunitowns = pd.DataFrame(columns = ['Notunitownvalues'])
Unitowns['Unitownvalues'] = Townames
Notunitowns['Notunitownvalues'] = Notowns
Unitowns = Unitowns.dropna(subset=['Unitownvalues'])
Notunitowns = Notunitowns.dropna(subset=['Notunitownvalues'])
return
run_ttest()
from scipy import stats
stats.ttest_ind(Unitowns['Unitownvalues'],Notunitowns['Notunitownvalues'])
然而,我的输出是:
Ttest_indResult(statistic=nan, pvalue=nan)
我不明白这是为什么。
我删除了上面的 NAN 值:Unitowns['Unitownvalues']
和 Notunitowns['Notunitownvalues'].
有人能帮帮我吗?
确保添加最后一个参数(假设您正在比较的两个数据集的方差将相等 ):
stats.ttest_ind(Unitowns['Unitownvalues'],Notunitowns['Notunitownvalues'],equal_var=True)
而不是:
stats.ttest_ind(Unitowns['Unitownvalues'],Notunitowns['Notunitownvalues'])
这给了我一个输出:
Ttest_indResult(statistic=0.38697667088831, pvalue=0.69878181110717441)