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

DEPR: positional indexing on Series __getitem__/__setitem__ #53201

Merged
merged 10 commits into from
May 19, 2023

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

xref #50617, possibly closes

@mroeschke mroeschke added Indexing Related to indexing on series/frames, not to indexes themselves Deprecate Functionality to remove in pandas labels May 12, 2023
Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

pandas/tests/series/methods/test_values.py Show resolved Hide resolved
Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

if index is d0:
warn = FutureWarning
with tm.assert_produces_warning(warn, match=msg):
assert s.get(10, "z") == "z"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this case raise a FutureWarning? I would expect Series.get to always act like label based indexing with fallback

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NDFrame.get is a try/except around __getitem__. xref #17928

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that's annoying. Okay makes sense here

@mroeschke mroeschke added this to the 2.1 milestone May 19, 2023
@mroeschke mroeschke merged commit 7b22448 into pandas-dev:main May 19, 2023
@mroeschke
Copy link
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the depr-setitem branch May 19, 2023 21:28
topper-123 pushed a commit to topper-123/pandas that referenced this pull request May 22, 2023
…ev#53201)

* DEPR: positional indexing on Series __getitem__/__setitem__

* troubleshoot docs

* troubleshoot docs

* update doc

* update docs

* docs

* update fixture

* update doctest
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
…ev#53201)

* DEPR: positional indexing on Series __getitem__/__setitem__

* troubleshoot docs

* troubleshoot docs

* update doc

* update docs

* docs

* update fixture

* update doctest
galipremsagar added a commit to rapidsai/cudf that referenced this pull request Dec 19, 2023
…em__ (#14654)

This PR deprecates positional access in `Series.__getitem__` when a label-based index is present.

xref: pandas-dev/pandas#53201

On `pandas_2.0_feature_branch`:

```
= 260 failed, 101179 passed, 2091 skipped, 954 xfailed, 312 xpassed in 1104.58s (0:18:24) =
```

This PR:
```
= 248 failed, 101190 passed, 2091 skipped, 954 xfailed, 312 xpassed in 1105.78s (0:18:25) =
```
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 this pull request may close these issues.

3 participants