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

API: should Series.get be strictly label based or allow positional? #17928

Open
jorisvandenbossche opened this issue Oct 20, 2017 · 2 comments
Open
Labels
API Design Indexing Related to indexing on series/frames, not to indexes themselves Needs Discussion Requires discussion from core team before further action

Comments

@jorisvandenbossche
Copy link
Member

The implementation of Series.get currenlty simply is:

def get(self, key, default=None):
    try:
        return self[key]
    except (KeyError, ValueError, IndexError):
        return default

So it is simply using [] / __getitem__ under the hood.

Somehow I think this is the expected thing, but the consequence is that it brings along all complexities of __getitem__ in pandas (whether to fallback to positional or not ..).

So, if we want, we could make get more strict by using loc under the hood (and it should be possible to do that with a deprecation in a first phase for those cases that loc raises but [] returns a value).

@jbrockmendel jbrockmendel added the Indexing Related to indexing on series/frames, not to indexes themselves label Feb 8, 2020
@mroeschke mroeschke added Deprecate Functionality to remove in pandas Needs Discussion Requires discussion from core team before further action and removed API Design labels Jun 12, 2021
@mroeschke mroeschke added API Design and removed Deprecate Functionality to remove in pandas labels Jun 7, 2022
@jbrockmendel
Copy link
Member

Discussed this on the dev call today, agreed we expect this to be label-based. No one felt strongly enough about this to want to deprecate the current behavior, but noted that if __getitem__ is deprecated (xref #50617) that will be a natural consequence. There was also mention of deprecating get entirely, which was also luke-warm (no one would object to it, but no one was actively interested)

@jbrockmendel
Copy link
Member

Discussed on yesterday's dev call. I advocated deprecating get entirely, no one else seemed to like that idea. There was agreement that deprecating to limit to a scalar input would be an improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Indexing Related to indexing on series/frames, not to indexes themselves Needs Discussion Requires discussion from core team before further action
Projects
None yet
Development

No branches or pull requests

3 participants