Skip to content

Calling shift(n != 0) on an empty DatetimeIndex raises an IndexError #14811

Closed
@chazmo03

Description

@chazmo03

Calling shift(0) on an empty DatetimeIndex seems to return an empty index, but calling shift(n) with a non-zero n raises an IndexError. I would expect this to return an empty index.

# this works
pd.date_range(start='20161021', end='20161021', freq='BM').shift(0)

# this raises
pd.date_range(start='20161021', end='20161021', freq='BM').shift(1)
# IndexError: index 0 is out of bounds for axis 0 with size 0

pd.__version__
# u'0.18.1'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions