我在下面有以下命令: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'].有人能帮帮我吗?
1 回答
www说
TA贡献1775条经验 获得超8个赞
确保添加最后一个参数(假设您正在比较的两个数据集的方差相等):
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)
添加回答
举报
0/150
提交
取消