Python 我有两行名称相同,但列中的值不同。我想知道如何使用列值删除其中一行

Python 我有两行名称相同,但列中的值不同。我想知道如何使用列值删除其中一行,python,pandas,Python,Pandas,我尝试了drop(),但它同时删除了两行。我甚至尝试转置数据帧,然后删除列,但它同时删除了这两列。请注意,我不想使用“行编号”来排除该行。我想使用其他列中的值删除其中一行。提前谢谢你 purchase_1 = pd.Series({'Name': 'Chris', 'Item Purchased': 'Dog Food', 'Cost': 22.50}) purchase_2 = pd.Series(

我尝试了drop(),但它同时删除了两行。我甚至尝试转置数据帧,然后删除列,但它同时删除了这两列。请注意,我不想使用“行编号”来排除该行。我想使用其他列中的值删除其中一行。提前谢谢你

purchase_1 = pd.Series({'Name': 'Chris',
                        'Item Purchased': 'Dog Food',
                        'Cost': 22.50})
purchase_2 = pd.Series({'Name': 'Kevyn',
                        'Item Purchased': 'Kitty Litter',
                        'Cost': 2.50})
purchase_3 = pd.Series({'Name': 'Vinod',
                        'Item Purchased': 'Bird Seed',
                        'Cost': 5.00})
purchase_4 = pd.Series({'Name': 'Vinod',
                        'Item Purchased': 'Dog Food',
                        'Cost': 5.00})
df1 = pd.DataFrame([purchase_1, purchase_2, purchase_3, purchase_4], index=['Store 1', 'Store 1', 'Store 2', 'Store 2'])

''' 
df::

         Name   Item Purchased  Cost
Store 1  Chris   Dog Food      22.5
Store 1  Kevyn   Kitty Litter   2.5
Store 2  Vinod   Bird Seed      5.0
Store 2  Vinod   Dog Food       5.0
'''
预期输出::

     One of the 'Store 1' rows deleted using values from some other column value like 'Dog Food' or 'Kitty Litter' or 22.5 or 2.5

这将返回“购买的物品”列中不包含“狗粮”的所有行:


更改逻辑-选择no
Dog Food中的所有行
我不想排除包含“Dog Food”的行。我想知道如何根据列值删除具有相同名称的两行中的1行
new_df = df[df["Item Purchased"] != "Dog Food"]