【发布时间】:2022-08-17 16:21:08
【问题描述】:
我正在对数据集列进行位置过滤。我正在使用类似的东西:
locations_list = [\"london\", \"new york\", \"berlin\", \"texas\"]
然后我使用过滤列
df[df[\"location\"].str.contains(r\'\\b(?:{})\\b\'.format(\'|\'.join(location_list))]
它可以工作,但它会选择像“新西兰”这样的地方,假设是因为它单独搜索新的。有没有办法解决这个问题?
-
请添加带有示例数据的minimal reproducible example,以便我们重现您的错误。另见How to make good reproducible pandas examples。