Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ghost opened this issue Nov 24, 2012 · 0 comments · Fixed by #2349
Closed

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

ghost opened this issue Nov 24, 2012 · 0 comments · Fixed by #2349
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Nov 24, 2012

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()
@wesm wesm closed this as completed in 0e942cc Nov 25, 2012
wesm added a commit that referenced this issue Nov 25, 2012
* y-p/fix_pop_with_dupe_columns:
  DOC: docstring of Index.get_loc, clarify return type
  TST: split_block_at() after changes
  BUG: deletion of non-unique column. closes #2347
  TST: add tests for com.split_ranges()
  ENH: add com.split_ranges util function
  TST: df.pop() of non-unique column
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant