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

BUG: del in Series gives strange errors #5542

Closed
dsm054 opened this issue Nov 18, 2013 · 2 comments · Fixed by #5544

Comments

@dsm054
Copy link
Contributor

commented Nov 18, 2013

I'm not sure whether del someseries[something] is supposed to work or not, although there is a Series.__delitem__ method so maybe at some point it was. And .drop() seems to work, so it's not super-important. But ISTM users shouldn't see this:

>>> pd.__version__
'0.12.0-1114-g4d0632b'
>>> ser = pd.Series(range(5))
>>> del ser[0]
Traceback (most recent call last):
  File "<ipython-input-62-e967e45427c2>", line 1, in <module>
    del ser[0]
  File "/usr/local/lib/python2.7/dist-packages/pandas-0.12.0_1114_g4d0632b-py2.7-linux-i686.egg/pandas/core/generic.py", line 1057, in __delitem__
    self._data.delete(key)
  File "/usr/local/lib/python2.7/dist-packages/pandas-0.12.0_1114_g4d0632b-py2.7-linux-i686.egg/pandas/core/internals.py", line 2818, in delete
    self.set_items_norename(new_items)
  File "/usr/local/lib/python2.7/dist-packages/pandas-0.12.0_1114_g4d0632b-py2.7-linux-i686.egg/pandas/core/internals.py", line 2923, in set_items_norename
    self.set_axis(0, value, maybe_rename=False, check_axis=False)
TypeError: set_axis() got an unexpected keyword argument 'maybe_rename'

>>> del ser[0]
Traceback (most recent call last):
  File "<ipython-input-63-e967e45427c2>", line 1, in <module>
    del ser[0]
  File "/usr/local/lib/python2.7/dist-packages/pandas-0.12.0_1114_g4d0632b-py2.7-linux-i686.egg/pandas/core/generic.py", line 1057, in __delitem__
    self._data.delete(key)
  File "/usr/local/lib/python2.7/dist-packages/pandas-0.12.0_1114_g4d0632b-py2.7-linux-i686.egg/pandas/core/internals.py", line 2814, in delete
    self._delete_from_all_blocks(loc, item)
  File "/usr/local/lib/python2.7/dist-packages/pandas-0.12.0_1114_g4d0632b-py2.7-linux-i686.egg/pandas/core/internals.py", line 2945, in _delete_from_all_blocks
    i, _ = self._find_block(item)
TypeError: 'NoneType' object is not iterable

That the error message isn't the same both times is a little disturbing in any case, because that suggests something stateful changed, which it's hard to believe can be right.

@jreback

This comment has been minimized.

Copy link
Contributor

commented Nov 18, 2013

this should deleted the item with index 0
inplace

prob no tests on it

prob didn't work in 0.12 and prior

@dsm054

This comment has been minimized.

Copy link
Contributor Author

commented Nov 18, 2013

Well, that's reassuring, anyway -- an in-place deletion of index 0 was exactly what I was expecting to happen. :^)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.