Filter pandas dataframe by list

后端 未结 3 775
谎友^
谎友^ 2020-12-11 22:29

I have a dataframe that has a row called \"Hybridization REF\". I would like to filter so that I only get the data for the items that have the same label as one of the items

3条回答
  •  天命终不由人
    2020-12-11 23:05

    Suppose df is your dataframe, lst is our list of labels.

    df.loc[ df.index.isin(lst), : ]
    

    Will display all rows whose index matches any value of the list item. I hope this helps solve your query.

提交回复
热议问题