我有一个与此类似的大数据帧:
In [1]: grades
Out[1]:
course1 course2
school class student
school1 class1 student1 2 2
student2 3 2
student3 1 3
student4 3 1
student5 3 1
... ... ...
class3 student86 3 1
student87 2 2
student88 1 1
student89 3 3
student90 0 1
[90 rows x 2 columns]
我想计算样本学校和每个子样本班级的成绩的曼惠特尼排名测试。如何使用pandas和scipy.stats.mannwhitneyu在不遍历数据帧的情况下实现这一点?在
两个调用的函数是
然后按学校计算曼惠特尼U:
^{pr2}$按班级来做:
levels
参数中的数字表示多重索引的级别。因此,按学校按0级分组,按学校/班级组合按0级和1级分组。在相关问题 更多 >
编程相关推荐