Using .loc with a MultiIndex in pandas?

半城伤御伤魂 提交于 2019-11-30 06:15:30

If you are on version 0.14, you can simply pass a tuple to .loc as below:

df.loc[('at', [1,3,4]), 'Dwell']

Try the cross-section indexing:

In [68]: df.xs('at', level='QGram', drop_level=False).loc[[1,4]]
Out[68]: 
        Char  Dwell  Flight  ND_Offset  Offset
QGram                                         
at    1    t    180       0   0.108363       5
      4    a     20     180   0.000000       0
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!