[英]Sorting a pandas DataFrame by one level of a MultiIndex
I have a MultiIndexed pandas DataFrame that needs sorting by one of the indexers. 我有一个MultiIndexed pandas DataFrame,需要按索引器之一进行排序。 Here is a snippet of the data: 以下是数据片段:
gene VIM
treatment dose time
TGFb 0.1 2 -0.158406
1 2 0.039158
10 2 -0.052608
0.1 24 0.157153
1 24 0.206030
10 24 0.132580
0.1 48 -0.144209
1 48 -0.093910
10 48 -0.166819
0.1 6 0.097548
1 6 0.026664
10 6 -0.008032
I'm looking to sort the data so that the time index is in ascending order. 我正在寻找对数据进行排序,以便时间索引按升序排列。 My first thoughts was to use pandas.sort_values
but it seems this doesn't work on the index. 我最初的想法是使用pandas.sort_values
但似乎对索引不起作用。 Does anybody know of a way to do this? 有人知道这样做的方法吗? Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.