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

ENH: Better Exception when trying to set on Series with tuple-index. #4759

Closed
jtratner opened this issue Sep 6, 2013 · 0 comments · Fixed by #4837
Closed

ENH: Better Exception when trying to set on Series with tuple-index. #4759

jtratner opened this issue Sep 6, 2013 · 0 comments · Fixed by #4837
Assignees
Milestone

Comments

@jtratner
Copy link
Contributor

jtratner commented Sep 6, 2013

Fix this Exception to be better (probably the same tuple-index error or something...)

>>> import pandas.util.testing as tm
>>> ts = tm.makeTimeSeries()
>>> ts[:, 2] = None
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "pandas/core/series.py", line 1061, in __setitem__
    self._set_with(key, value)
  File "pandas/core/series.py", line 1103, in _set_with
    self._set_labels(key, value)
  File "pandas/core/series.py", line 1110, in _set_labels
    indexer = self.index.get_indexer(key)
  File "pandas/core/index.py", line 920, in get_indexer
    return this.get_indexer(target, method=method, limit=limit)
  File "pandas/core/index.py", line 935, in get_indexer
    indexer = self._engine.get_indexer(target.values)
  File "index.pyx", line 267, in pandas.index.IndexEngine.get_indexer (pandas/index.c:5079)
  File "hashtable.pyx", line 722, in pandas.hashtable.PyObjectHashTable.lookup (pandas/hashtable.c:11394)
TypeError: unhashable type

Compare to this exception for getitem for the same thing:

>>> ts[:, 2]
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "pandas/core/series.py", line 944, in __getitem__
    return self._get_with(key)
  File "pandas/core/series.py", line 961, in _get_with
    return self._get_values_tuple(key)
  File "pandas/core/series.py", line 1007, in _get_values_tuple
    raise ValueError('Can only tuple-index with a MultiIndex')
ValueError: Can only tuple-index with a MultiIndex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant