Skip to content

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

Open
@jorisvandenbossche

Description

@jorisvandenbossche

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignIndexingRelated to indexing on series/frames, not to indexes themselvesNeeds DiscussionRequires discussion from core team before further action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions