小编Pab*_*vas的帖子

基于DataFrame将参数传递给stats.friedmanchisquare的正确方法是什么?

我试图从具有形状的数据传递值到stats.friedmanchisquare.df(11,17)

这是什么样的工作,我(在这个例子中只为三排):

df = df.as_matrix()
print stats.friedmanchisquare(df[1, :], df[2, :], df[3, :])
Run Code Online (Sandbox Code Playgroud)

产量

(16.714285714285694, 0.00023471398805908193)
Run Code Online (Sandbox Code Playgroud)

但是,当我想要使用所有11行时, 代码行太长df.

首先,我尝试以下列方式传递值:

df = df.as_matrix()
print stats.friedmanchisquare([df[x, :] for x in np.arange(df.shape[0])])
Run Code Online (Sandbox Code Playgroud)

但我得到:

ValueError: 
Less than 3 levels.  Friedman test not appropriate.
Run Code Online (Sandbox Code Playgroud)

其次,我也尝试不将它转换为矩阵形式,将其作为DataFrame(这对我来说很理想),但我想这还不支持,或者我做错了:

print stats.friedmanchisquare([row for index, row in df.iterrows()])
Run Code Online (Sandbox Code Playgroud)

这也给了我错误:

ValueError: 
Less than 3 levels.  Friedman test not appropriate.
Run Code Online (Sandbox Code Playgroud)

所以,我的问题是:基于参数传递给stats.friedmanchisquare的正确方法是什么df?(甚至使用其df.as_matrix()代表)

您可以在此处以csv格式下载我的数据帧并使用以下方式阅读: …

python numpy scipy pandas

8
推荐指数
1
解决办法
1547
查看次数

标签 统计

numpy ×1

pandas ×1

python ×1

scipy ×1