Skip to content

DEPR: disallow series[[slice(...)]] #31299

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

Closed
jbrockmendel opened this issue Jan 25, 2020 · 2 comments · Fixed by #31333
Closed

DEPR: disallow series[[slice(...)]] #31299

jbrockmendel opened this issue Jan 25, 2020 · 2 comments · Fixed by #31333
Labels
Deprecate Functionality to remove in pandas Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@jbrockmendel
Copy link
Member

One of the more convoluted parts of Series.__getitem__ is for handling single-entry lists that contain a slice, where we end up just returning self[key[0]]. We have two tests that hit this path, but it isn't clear to me why this should be supported.

@jorisvandenbossche
Copy link
Member

Can you give a code example? This isn't involved with MultiIndex?

@jbrockmendel
Copy link
Member Author

Can you give a code example? This isn't involved with MultiIndex?

dti = pd.date_range("2016-01-01", periods=5)
ser = pd.Series(range(5), index=dti)
key = [slice(0, 3)]

>>> ser[key]
pandas/core/internals/blocks.py:313: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  return self.values[slicer]
pandas/core/arrays/datetimelike.py:542: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.

  result = getitem(key)
2016-01-01    0
2016-01-02    1
2016-01-03    2
dtype: int64

@jbrockmendel jbrockmendel added Deprecate Functionality to remove in pandas Indexing Related to indexing on series/frames, not to indexes themselves labels Jan 26, 2020
@jreback jreback added this to the 1.1 milestone Feb 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants