📜  python loc id in list - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:56.140000             🧑  作者: Mango

代码示例1
In [30]: df = pd.DataFrame({'subscriber_id':[1,2,3,4,5]})
'''       subscriber_id
    0              1
    1              2
    2              3
    3              4
    4              5 '''

mask = df['subscriber_id'].isin([2,4,5])
''' 0    False
    1     True
    2    False
    3     True
    4     True '''

df.loc[mask]
'''       subscriber_id
    1              2
    3              4
    4              5 '''