pandas: Boolean indexing with multi index

前端 未结 6 1747
再見小時候
再見小時候 2021-02-08 14:52

There are many questions here with similar titles, but I couldn\'t find one that\'s addressing this issue.

I have dataframes from many different origins, and I want to f

6条回答
  •  温柔的废话
    2021-02-08 15:20

    The more readable (to my liking) solution is to reindex the boolean series (dataframe) to match index of the multi-index df:

    df.loc[filt.reindex(df.index, level='a')]
    

提交回复
热议问题