Skip to content

Inconsistent keyword argument name for the 'periods' in pandas.Index.shift for a DatetimeIndex #22458

@SaberStrat

Description

@SaberStrat

The actual implementation of pandas.Index.shift for a datetime-like index takes a differently named parameter for the number of shifts than the base method.

It should be named periods, which would also be consistent with the pandas.DataFrame.shift or pandas.Series.shift methods. But for a DatetimeIndex it's n.

See:
https://github.com/pandas-dev/pandas/blob/v0.23.4/pandas/core/indexes/base.py#L2586
vs.
https://github.com/pandas-dev/pandas/blob/v0.23.4/pandas/core/indexes/datetimelike.py#L1021

With a DatetimeIndex, following the documentation leads to a

TypeError: shift() got an unexpected keyword argument 'periods'

If this is somehow intended, then it should be stated so in the docstring for pandas.Index.shift.

pandas version is 0.23.4

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