我认为这个确切的问题还没有得到回答,所以这里是。
我有一个 Pandas 数据框,我想选择 A 列或 B 列中包含字符串的所有行。
假设数据框如下所示:
d = {'id':["1", "2", "3", "4"],
'title': ["Horses are good", "Cats are bad", "Frogs are nice", "Turkeys are the best"],
'description':["Horse epitome", "Cats bad but horses good", "Frog fancier", "Turkey tome, not about horses"],
'tags':["horse, cat, frog, turkey", "horse, cat, frog, turkey", "horse, cat, frog, turkey", "horse, cat, frog, turkey"],
'date':["2019-01-01", "2019-10-01", "2018-08-14", "2016-11-29"]}
dataframe = pandas.DataFrame(d)
Run Code Online (Sandbox Code Playgroud)
这使:
id title description tag date
1 "Horses are good" "Horse epitome" …Run Code Online (Sandbox Code Playgroud)