【发布时间】:2021-02-01 23:19:35
【问题描述】:
我想在包含列表中任何子字符串的列中选择这些行。这就是我现在所拥有的。
product = ['LID', 'TABLEWARE', 'CUP', 'COVER', 'CONTAINER', 'PACKAGING']
df_plastic_prod = df_plastic[df_plastic['Goods Shipped'].str.contains(product)]
df_plastic_prod.info()
df_plastic 示例
Name Product
David PLASTIC BOTTLE
Meghan PLASTIC COVER
Melanie PLASTIC CUP
Aaron PLASTIC BOWL
Venus PLASTIC KNIFE
Abigail PLASTIC CONTAINER
Sophia PLASTIC LID
所需的 df_plastic_prod
Name Product
Meghan PLASTIC COVER
Melanie PLASTIC CUP
Abigail PLASTIC CONTAINER
Sophia PLASTIC LID
提前致谢!感谢您对此提供的任何帮助!
【问题讨论】:
标签: python python-3.x pandas dataframe substring