此问题已在此处有答案:
Filter pandas DataFrame by substring criteria(17回答)
4天前关闭。
所以我现在有这个我对这个东西很陌生
import pandas as pd
file_name = 'Should_work2222.csv'
df = pd.read_csv(file_name)[['Assignees_y', 'Serials']]
result = pd.DataFrame(df)
print(result)
这段代码为我工作,我得到了我想要的,但我试图只接收某些单词,如Fastenal与序列号,我知道我可以使用Excel只得到我想要的信息,但我想尝试使用Python
Assignees_y Serials
0 Fastenal-OB(any)-locker 110 376txk1233
1 Fastenal - locker 70 376TXK1235
2 Fastenal-locker 105 376txk1244
3 Fastenal - OB Dock 111 376txk6431
4 bin 376txr4241
5 Missing 376txr5214
6 lost 376txk5352
7 lost 376txk1324
8 lost 376TXR6446
9 available in master 376TXK5335
10 IB Receive 376txk1424
11 IB Receive 376txk1601
12 IB Receive 376TYR5366
13 IB Receive 376TXR5535
14 Fastenal - IB Rcv locker 91 376txk6434
15 Fastenal - IB Rcvlocker 93 376txr5553
16 Fastenal - IB Rcv locker 94 376TXR5333
17 Fastenal - IB Stw - locker 102 376TXK3532
18 Fastenal - IB Stw - locker 103 376txk5353
19 IB Rcv 376txk5322
20 lost 376txk2625
21 OB 376txk2434
22 Fastenal-pick- locker 82 376txk6454
23 Fastenal-pack-locker 84 376txk5343
24 Fastenal-pack-locker 90 376TXK1244
我想把这个处理掉只买Fastenal和他们的系列
2条答案
按热度按时间h9a6wy2h1#
使用
str.contain
方法:l2osamch2#
删除不包含文本“Fastenal”的所有行:
它打印: