loc利用index的名称,来获取想要的行(或列) 如下,获取y,1列,'a','b'行的数据 print(df.loc[['a', 'b'], ['y', 1]]) # 结果如下 y 1 a NaN NaN b NaN NaN