【发布时间】:2014-09-26 19:42:32
【问题描述】:
这是我的多索引数据框:
A B
Net Upper Lower Mid Zsore
Answer option
More than once a day 0% 0.22% -0.12% 2 65
Once a day 0% 0.32% -0.19% 3 45
Several times a week 2% 2.45% 1.10% 4 78
Once a week 1% 1.63% -0.40% 6 65
我想通过 COLUMN NAME 在第二层构建一个子集(没什么花哨的),它只保留以下列“Net、Upper、Zscore”
Net Upper Zsore
Answer option
More than once a day 0% 0.22% 65
Once a day 0% 0.32% 45
Several times a week 2% 2.45% 78
Once a week 1% 1.63% 65
我的尝试失败了,我猜它失败了,因为我不知道如何解释 2 个级别的列?
df = df[[u'Net',u'Upper',u'Zsore']]
【问题讨论】:
标签: python pandas dataframe subset multi-index