就像这里的数据一样,如果我有多个标题,我们如何才能读取想要的特定列,谢谢!
machine A A B
date 12-01 12-02 12-01
number #1 #2 #2
0.223 0.224 0.226
0.333 0.444 0.234
0.234 0.124 0.456
答案 0 :(得分:1)
您必须使用xs函数: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.xs.html
例如
print(df.xs('A', level='machine', axis=1))
或
print(df.xs('#1', level='number', axis=1))