You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, some non-scalar input is hashable (e.g., Ellipsis):
In [2]: import pandas as pd
In [3]: ss = pd.Series(range(10)).to_sparse()
In [4]: ss[...]
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-4-f0ccf654123b> in <module>()
----> 1 ss[...]
/Users/shoyer/dev/pandas/pandas/sparse/series.pyc in __getitem__(self, key)
369 if isinstance(key, (int, np.integer)):
370 return self._get_val_at(key)
--> 371 raise Exception('Requested index not in this series!')
372
373 except TypeError:
Exception: Requested index not in this series!
(this should return the entire sparse series)
This logic is also problematic because it relies on get_loc always throwing TypeError for invalid input. So this could use some cleanup, ideally checking directly if the input is hashable. And it probably shouldn't be raising a generic Exception, either.
SparseSeries currently relies on the assumption that all non-scalar input will raise a
TypeError
(because it won't be hashable) when used as input toIndex.get_loc
:https://github.com/pydata/pandas/blob/bb9c311f36fbf508d11f2eabe3fdbdd010abf8c0/pandas/sparse/series.py#L361
However, some non-scalar input is hashable (e.g.,
Ellipsis
):(this should return the entire sparse series)
This logic is also problematic because it relies on
get_loc
always throwingTypeError
for invalid input. So this could use some cleanup, ideally checking directly if the input is hashable. And it probably shouldn't be raising a genericException
, either.xref tslib.pyx change/discussion in #9258
The text was updated successfully, but these errors were encountered: