Skip to content

del df[k] fails for a non-unique key #2347

@ghost

Description

import pandas as pd
df=pd.DataFrame({0:[0,1],1:[0,1],2:[4,5]})
df.columns=["a","b","a"]
res=df.pop("a")
...

/home/user1/src/pandas/pandas/core/internals.py in _delete_from_block(self, i, item)
    971         """
    972         block = self.blocks.pop(i)
--> 973         new_left, new_right = block.split_block_at(item)
    974 
    975         if new_left is not None:

/home/user1/src/pandas/pandas/core/internals.py in split_block_at(self, item)
    195             return None, None
    196 
--> 197         if loc == 0:
    198             # at front
    199             left_block = None

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions