Filtering multiple items in a multi-index Python Panda dataframe

后端 未结 4 2021
轮回少年
轮回少年 2020-12-13 17:29

I have the following table:

Note: Both NSRCODE and PBL_AWI are index\'s

Note: the % Of area column would be filled out just have not done so yet.

<         


        
4条回答
  •  星月不相逢
    2020-12-13 17:49

    Another (maybe cleaner) way might be this one:

    print(df[df.index.isin(['Lake', 'River', 'Upland'], level=1)])
    

    The parameter level specifies the index number (starting with 0) or index name (here: level='PBL_AWI')

提交回复
热议问题