0
我有一个看起来像这样删除多个大熊猫据帧行,其中列值是这个或那个
Label Type
Name
ppppp Base brute UnweightedBase
pbaaa Base Base
pb4a1 Très à gauche Category
pb4a2 A gauche pb4a2 Category
pb4a3 Au centre pb4a3 Category
pb4a4 A droite pb4a4 Category
如果数据帧的“类型”列的值是“UnweightedBase”和“基地”,我想是删除来自数据。
我可以用下面的代码做一次这只是一个项目:
to_del = df[df['Type'] == "UnweightedBase"].index.tolist()
df= df.drop(to_del, axis)
return df
如何修改我的代码,这样我就可以一次删除多个值?
我的失败尝试:
to_del = df[df['Type'] in ["UnweightedBase","Base"]].index.tolist()
df= df.drop(to_del, axis)
return df
想通了,这是我想要的东西:to_del =元[元[ '类型'] ISIN(type_val)index.tolist() – 2014-10-02 16:28:44
好的,谢谢信息! – 2014-10-02 16:58:13