Pandas: Check if row exists with certain values

前端 未结 3 1600
失恋的感觉
失恋的感觉 2020-12-25 10:24

I have a two dimensional (or more) pandas DataFrame like this:

>>> import pandas as pd
>>> df = pd.DataFrame([[0,1],[2,3],[4,5]], columns=[         


        
3条回答
  •  半阙折子戏
    2020-12-25 10:52

    If you also want to return the index where the matches occurred:

    index_list = df[(df['A'] == 2)&(df['B'] == 3)].index.tolist()
    

提交回复
热议问题