根据列值而不是索引值从pandas数据框中排除行

yos*_*rry 15 python pandas

我查看了数据框列中的唯一值 - 我拥有的pandas.并且在其中一个列中有一些我不想包含的名称,如何在不使用索引值表示法的情况下从数据框中删除这些行,而是说如果行值="this"则删除

喜欢...

new = df.copy

df['some column'].drop_values('this','that','other')
Run Code Online (Sandbox Code Playgroud)

beh*_*uri 33

请参阅索引isin(也是,布尔索引):

mask = df['some column'].isin(['this', 'that', 'other'])
df[~mask]
Run Code Online (Sandbox Code Playgroud)