Skip to content

BUG: Series.get() does not return default value in case one of slice(n,m) is not found #36257

Open
@phofl

Description

@phofl
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

ds = pd.Series(['a', 'b', 'c'])
print(ds.get([1,-1]))
print(ds.get(slice(-1,2)))

Problem description

The first get call returns the default value None as expected. The second returns an empty series. This seems inconsistent. I propose that we return here None too.

Expected Output

None and None

Output of pd.show_versions()

master

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSeriesSeries data structure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions