我认为您需要isin
通过以下方式反转条件~
:
salesdf[~salesdf['Document type'].isin(['AVC', 'CC','CDI', 'BSX','BTR','FAF'])]
样品:
salesdf = pd.DataFrame({
'Document type': ['AVC','CDI','CC','a','b','FAF','BTR','c','BSX']
})
print (salesdf)
Document type
0 AVC
1 CDI
2 CC
3 a
4 b
5 FAF
6 BTR
7 c
8 BSX
a = salesdf.loc[(salesdf['Document type'] != 'AVC') &
(salesdf['Document type'] != 'CC') &
(salesdf['Document type'] != 'CDI') &
(salesdf['Document type'] != 'BSX') &
(salesdf['Document type'] != 'BTR') &
(salesdf['Document type'] != 'FAF')]
print (a)
Document type
3 a
4 b
7 c
b = salesdf[~salesdf['Document type'].isin(['AVC', 'CC','CDI', 'BSX','BTR','FAF'])]
print (b)
Document type
3 a
4 b
7 c